Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some broken wiki links #148

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
13 changes: 9 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ buildscript {
}
apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.10.2-1.5.4"
version = "1.10.2-1.5.9"
group= "ca.rivas.roguelike" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "RoguelikeDungeons"

sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = "1.6"
}

minecraft {
version = "1.10.2-12.18.0.2002-1.10.0"
version = "1.10.2-12.18.3.2185"
runDir = "run"
mappings = "snapshot_20160518"
//makeObfSourceJar = false
mappings = "snapshot_20161111"
makeObfSourceJar = false
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS=-Xmx2G

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/greymerk/roguelike/EntityJoinWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.util.Collection;

import greymerk.roguelike.treasure.loot.Loot;
import greymerk.roguelike.monster.IEntity;
import greymerk.roguelike.monster.MetaEntity;
import greymerk.roguelike.monster.MonsterProfile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityMob;
Expand Down Expand Up @@ -32,9 +34,12 @@ public void OnEntityJoinWorld(EntityJoinWorldEvent event) {
for(Object buff : effects){
if(Potion.getIdFromPotion(((PotionEffect) buff).getPotion()) == 4){
int level = ((PotionEffect) buff).getAmplifier();
Loot.addEquipment(world, level, entity);

IEntity metaEntity = new MetaEntity((Entity)mob);
MonsterProfile.equip(world, world.rand, level, metaEntity);
if(entity.isDead) event.setCanceled(true);
return;
}
}
}
}
}
7 changes: 4 additions & 3 deletions src/main/java/greymerk/roguelike/Roguelike.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid="Roguelike", name="Roguelike Dungeons", version=Roguelike.version, acceptableRemoteVersions="*")
@Mod(modid="roguelike", name="Roguelike Dungeons", version=Roguelike.version, acceptableRemoteVersions="*")

public class Roguelike {

// The instance of your mod that Forge uses.
@Instance("Roguelike")
@Instance("roguelike")
public static Roguelike instance;
public static final String version = "1.5.4";
public static final String version = "1.5.9";
public static final String date = "Mar 15th 2017";

// Says where the client and server 'proxy' code is loaded.
@SidedProxy(clientSide="greymerk.roguelike.ClientProxy", serverSide="greymerk.roguelike.CommonProxy")
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/greymerk/roguelike/citadel/CityGrounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public static void generate(IWorldEditor editor, Random rand, MinimumSpanningTre
start.add(new Coord(Citadel.EDGE_LENGTH * -3, 10, Citadel.EDGE_LENGTH * -3));
end = new Coord(pos);
end.add(new Coord(Citadel.EDGE_LENGTH * 3, 20, Citadel.EDGE_LENGTH * 3));
RectSolid.fill(editor, rand, start, end, theme.getPrimaryWall(), true, true);
RectSolid.fill(editor, rand, start, end, theme.getPrimary().getWall(), true, true);

start = new Coord(pos);
start.add(new Coord(Citadel.EDGE_LENGTH * -2, 20, Citadel.EDGE_LENGTH * -2));
end = new Coord(pos);
end.add(new Coord(Citadel.EDGE_LENGTH * 2, 30, Citadel.EDGE_LENGTH * 2));
RectSolid.fill(editor, rand, start, end, theme.getPrimaryWall(), true, true);
RectSolid.fill(editor, rand, start, end, theme.getPrimary().getWall(), true, true);

start = new Coord(pos);
start.add(new Coord(Citadel.EDGE_LENGTH * -1, 30, Citadel.EDGE_LENGTH * -1));
end = new Coord(pos);
end.add(new Coord(Citadel.EDGE_LENGTH, 40, Citadel.EDGE_LENGTH));
RectSolid.fill(editor, rand, start, end, theme.getPrimaryWall(), true, true);
RectSolid.fill(editor, rand, start, end, theme.getPrimary().getWall(), true, true);

Coord cursor = new Coord(pos);
cursor.add(Cardinal.UP, 20);
Expand All @@ -55,7 +55,7 @@ public static void generate(IWorldEditor editor, Random rand, MinimumSpanningTre
end = e.getPoints()[1].getPosition();
end.add(cursor);
end.add(Cardinal.DOWN, 20);
RectSolid.fill(editor, rand, start, end, theme.getPrimaryWall(), true, true);
RectSolid.fill(editor, rand, start, end, theme.getPrimary().getWall(), true, true);
}


Expand Down
10 changes: 7 additions & 3 deletions src/main/java/greymerk/roguelike/config/RogueConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public enum RogueConfig {

DONATURALSPAWN, LEVELRANGE, LEVELMAXROOMS, LEVELSCATTER, SPAWNFREQUENCY, GENEROUS, MOBDROPS, DIMENSIONWL, DIMENSIONBL,
PRECIOUSBLOCKS, LOOTING, DONOVELTYSPAWN, UPPERLIMIT, LOWERLIMIT, ROGUESPAWNERS;
PRECIOUSBLOCKS, LOOTING, DONOVELTYSPAWN, UPPERLIMIT, LOWERLIMIT, ROGUESPAWNERS, ENCASE, FURNITURE;

public static final String configDirName = "config/roguelike_dungeons";
public static final String configFileName = "roguelike.cfg";
Expand All @@ -35,6 +35,8 @@ public static String getName(RogueConfig option){
case UPPERLIMIT: return "upperLimit";
case LOWERLIMIT: return "lowerLimit";
case ROGUESPAWNERS: return "rogueSpawners";
case ENCASE: return "encase";
case FURNITURE: return "furniture";
default: return null;
}
}
Expand All @@ -59,6 +61,8 @@ public static String getName(RogueConfig option){
case UPPERLIMIT: return new Tuple<String, Integer>(getName(option), 100);
case LOWERLIMIT: return new Tuple<String, Integer>(getName(option), 60);
case ROGUESPAWNERS: return new Tuple<String, Boolean>(getName(option), true);
case ENCASE: return new Tuple<String, Boolean>(getName(option), false);
case FURNITURE: return new Tuple<String, Boolean>(getName(option), true);
default: return null;
}
}
Expand All @@ -79,6 +83,8 @@ private static void setDefaults(){
if(!instance.ContainsKey(getName(UPPERLIMIT)))setInt(UPPERLIMIT, (Integer) getDefault(UPPERLIMIT).getSecond());
if(!instance.ContainsKey(getName(LOWERLIMIT)))setInt(LOWERLIMIT, (Integer) getDefault(LOWERLIMIT).getSecond());
if(!instance.ContainsKey(getName(ROGUESPAWNERS))) setBoolean(ROGUESPAWNERS, (Boolean)getDefault(ROGUESPAWNERS).getSecond());
if(!instance.ContainsKey(getName(ENCASE))) setBoolean(ENCASE, (Boolean)getDefault(ENCASE).getSecond());
if(!instance.ContainsKey(getName(FURNITURE))) setBoolean(FURNITURE, (Boolean)getDefault(FURNITURE).getSecond());
}

public static double getDouble(RogueConfig option){
Expand Down Expand Up @@ -173,6 +179,4 @@ public static void reload(boolean force){
init();
}
}


}
67 changes: 57 additions & 10 deletions src/main/java/greymerk/roguelike/dungeon/Dungeon.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package greymerk.roguelike.dungeon;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import com.google.common.base.Charsets;
import com.google.common.io.Files;

import greymerk.roguelike.Roguelike;
import greymerk.roguelike.config.RogueConfig;
import greymerk.roguelike.dungeon.settings.ISettings;
Expand All @@ -13,8 +21,6 @@
import greymerk.roguelike.treasure.Treasure;
import greymerk.roguelike.treasure.TreasureManager;
import greymerk.roguelike.treasure.loot.Book;
import greymerk.roguelike.treasure.loot.ILoot;
import greymerk.roguelike.treasure.loot.Loot;
import greymerk.roguelike.util.WeightedChoice;
import greymerk.roguelike.worldgen.Cardinal;
import greymerk.roguelike.worldgen.Coord;
Expand All @@ -30,19 +36,51 @@

public class Dungeon implements IDungeon{


private static final String SETTINGS_DIRECTORY = RogueConfig.configDirName + "/settings";
public static SettingsResolver settingsResolver;

private DungeonGenerator generator;
private Coord pos;
private IWorldEditor editor;

static{
initResolver();
try{
RogueConfig.reload(false);
initResolver();
} catch(Exception e) {
// do nothing
}
}

public static void initResolver(){
public static void initResolver() throws Exception{
File settingsDir = new File(SETTINGS_DIRECTORY);

if(settingsDir.exists() && !settingsDir.isDirectory()){
throw new Exception("Settings directory is a file");
}

if(!settingsDir.exists()){
settingsDir.mkdir();
}

File[] settingsFiles = settingsDir.listFiles();
Arrays.sort(settingsFiles);

settingsResolver = new SettingsResolver();

Map<String, String> files = new HashMap<String, String>();

for(File file : Arrays.asList(settingsFiles)){
try {
String content = Files.toString(file, Charsets.UTF_8);
files.put(file.getName(), content);
} catch (IOException e) {
throw new Exception("Error reading file : " + file.getName());
}
}

settingsResolver.parseCustomSettings(files);

}


Expand All @@ -52,14 +90,23 @@ public Dungeon(IWorldEditor editor){
}

public void generateNear(Random rand, int x, int z){
if(Dungeon.settingsResolver == null) return;

int attempts = 50;

for(int i = 0;i < attempts;i++){
Coord location = getNearbyCoord(rand, x, z, 40, 100);

if(!validLocation(rand, location.getX(), location.getZ())) continue;

ISettings setting = settingsResolver.getSettings(editor, rand, location);
ISettings setting;

try{
setting = Dungeon.settingsResolver.getSettings(editor, rand, location);
} catch(Exception e){
return;
}


if(setting == null) return;

Expand All @@ -74,9 +121,9 @@ public void generate(ISettings settings, int inX, int inZ){

Random rand = getRandom(editor, this.pos.getX(), this.pos.getZ());
TreasureManager treasure = editor.getTreasure();
ILoot loot = Loot.getLoot();
settings.getLootRules().process(rand, loot, treasure);


settings.getLootRules().process(rand, treasure);
// TODO: Change start book details
Book book = new Book("Greymerk", "Statistics");
book.addPage("~Architect's Resource Notes~\n\n"
+ "StoneBrick: " + editor.getStat(Blocks.STONEBRICK) + "\n"
Expand All @@ -88,7 +135,7 @@ public void generate(ISettings settings, int inX, int inZ){
+ "TNT: " + editor.getStat(Blocks.TNT) + "\n"
+ "\n-Greymerk");
book.addPage("Roguelike Dungeons v" + Roguelike.version + "\n"
+ "June 29th 2016\n\n"
+ Roguelike.date + "\n\n"
+ "Credits\n\n"
+ "Author: Greymerk\n\n"
+ "Bits: Drainedsoul\n\n"
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/greymerk/roguelike/dungeon/DungeonNode.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package greymerk.roguelike.dungeon;

import java.util.Random;

import greymerk.roguelike.dungeon.base.IDungeonRoom;
import greymerk.roguelike.theme.ITheme;
import greymerk.roguelike.worldgen.Cardinal;
import greymerk.roguelike.worldgen.Coord;
import greymerk.roguelike.worldgen.IWorldEditor;
import greymerk.roguelike.worldgen.shapes.RectSolid;

public class DungeonNode {

Expand All @@ -28,6 +33,20 @@ public int getSize(){
return toGenerate.getSize();
}

public void encase(IWorldEditor editor, Random rand, ITheme theme){
IDungeonRoom room = this.getRoom();
int size = room.getSize();
Coord s = new Coord(this.getPosition());
Coord e = new Coord(s);
s.add(Cardinal.NORTH, size);
s.add(Cardinal.WEST, size);
s.add(Cardinal.DOWN, 3);
e.add(Cardinal.SOUTH, size);
e.add(Cardinal.EAST, size);
e.add(Cardinal.UP, 8);
RectSolid.fill(editor, rand, s, e, theme.getPrimary().getWall());
}

public Cardinal[] getEntrances(){
return this.entrances;
}
Expand Down
26 changes: 21 additions & 5 deletions src/main/java/greymerk/roguelike/dungeon/DungeonTunnel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import greymerk.roguelike.dungeon.segment.ISegment;
import greymerk.roguelike.dungeon.segment.ISegmentGenerator;
import greymerk.roguelike.dungeon.settings.LevelSettings;
import greymerk.roguelike.theme.ITheme;
import greymerk.roguelike.worldgen.BlockJumble;
import greymerk.roguelike.worldgen.Cardinal;
import greymerk.roguelike.worldgen.Coord;
Expand Down Expand Up @@ -39,20 +40,35 @@ public Iterator<Coord> iterator() {
return tunnel.iterator();
}

public void encase(IWorldEditor editor, Random rand, ITheme theme){
Coord s;
Coord e;
s = new Coord(this.start);
e = new Coord(this.end);
s.add(Cardinal.left(dir), 3);
s.add(Cardinal.UP, 3);
e.add(Cardinal.right(dir), 3);
e.add(Cardinal.DOWN, 3);
RectSolid.fill(editor, rand, s, e, theme.getPrimary().getWall());
}

public void construct(IWorldEditor editor, Random rand, LevelSettings settings){

MetaBlock air = BlockType.get(BlockType.AIR);

IBlockFactory wallBlocks = settings.getTheme().getPrimaryWall();
IBlockFactory floor = settings.getTheme().getPrimaryFloor();
IBlockFactory wallBlocks = settings.getTheme().getPrimary().getWall();
IBlockFactory floor = settings.getTheme().getPrimary().getFloor();
BlockJumble bridgeBlocks = new BlockJumble();
Coord s;
Coord e;

bridgeBlocks.addBlock(floor);
bridgeBlocks.addBlock(air);

Coord s = new Coord(this.start);
s = new Coord(this.start);
s.add(Cardinal.NORTH);
s.add(Cardinal.EAST);
Coord e = new Coord(this.end);
e = new Coord(this.end);
e.add(Cardinal.SOUTH);
e.add(Cardinal.WEST);
e.add(Cardinal.UP, 2);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/greymerk/roguelike/dungeon/LevelGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public static void generateLevelLink(IWorldEditor editor, Random rand, LevelSett
IDungeonRoom upstairs = new DungeonLinkerTop();
upstairs.generate(editor, rand, settings, oldEnd.getEntrances(), oldEnd.getPosition());

IStair stair = settings.getTheme().getPrimaryStair();
IStair stair = settings.getTheme().getPrimary().getStair();

Coord cursor = new Coord(start);
for (int i = 0; i < oldEnd.getPosition().getY() - start.getY(); i++){
editor.spiralStairStep(rand, cursor, stair, settings.getTheme().getPrimaryPillar());
editor.spiralStairStep(rand, cursor, stair, settings.getTheme().getPrimary().getPillar());
cursor.add(Cardinal.UP);
}
}
Expand Down
Loading