Skip to content

Commit

Permalink
NOVA Worldgen Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Jan 22, 2017
1 parent a61f3bd commit 69ffa52
Show file tree
Hide file tree
Showing 17 changed files with 360 additions and 110 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

# Sources
!/src
!/mc17
!/mc18
!/minecraft

# github
!/.gitignore
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
plugins {
id "java"
id "nova.gradle" version "0.2.3"
id "nova.gradle" version "0.2.6"
id "maven-publish"
id "com.jfrog.artifactory" version "3.1.1"
}


apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle"

dependencies novaApi("0.1.0-SNAPSHOT")
dependencies {
compile nova(nova_version)
}

nova {
wrappers {
"17" {
wrapper "nova.wrapper.mc1710:NovaWrapper-MC1.7.10:0.1-SNAPSHOT:deobf"
runtime project(":mc17")
wrapper "nova.core:NOVA-Core-Wrapper-MC1.7:$nova_version"
runtime project(":minecraft:1.7")
}

"18" {
wrapper "nova.wrapper.mc18:NovaWrapper-MC1.8:0.1-SNAPSHOT:deobf"
runtime project(":mc18")
wrapper "nova.core:NOVA-Core-Wrapper-MC1.8:$nova_version"
runtime project(":minecraft:1.8")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version = 0.0.1-SNAPSHOT
group = nova.worldgen
novaVersion = 0.1.0-SNAPSHOT
nova_version = 0.1.0-SNAPSHOT

packaging = jar
info.inceptionYear = 2015
Expand Down
4 changes: 4 additions & 0 deletions minecraft/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*

!/build.gradle
!/.gitignore
19 changes: 19 additions & 0 deletions minecraft/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
subprojects {
buildscript {
repositories {
mavenCentral()
maven {
name "forge"
url "http://files.minecraftforge.net/maven"
}
maven {
name "sonatype"
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
// Minecraft 1.11 requires newer ForgeGradle, while 1.7 and 1.8 require older.
classpath 'net.minecraftforge.gradle:ForgeGradle:' + property('forgeGradleVersion')
}
}
}
5 changes: 3 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
rootProject.name = "NOVA-WORLDGEN"
rootProject.name = "NOVA-Worldgen"

include "mc17", "mc18"
include "minecraft:1.8"
include "minecraft:1.7"
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2017 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/

package nova.internal.worldgen.depmodules;

import nova.worldgen.WorldgenManager;
import nova.worldgen.world.WorldInfo;
import se.jbee.inject.bind.BinderModule;
import se.jbee.inject.util.Scoped;

/**
*
* @author ExE Boss
*/
public class WorldgenModule extends BinderModule {

@Override
protected void declare() {
per(Scoped.APPLICATION).bind(WorldgenManager.class).toConstructor();
}
}
20 changes: 20 additions & 0 deletions src/main/java/nova/worldgen/Chunk.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* Copyright (c) 2015 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/

package nova.worldgen;

import nova.core.block.Block;
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/nova/worldgen/WorldgenManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2015 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/

package nova.worldgen;

import nova.worldgen.generator.Generator;
import nova.core.event.bus.GlobalEvents;
import nova.core.util.registry.Manager;
import nova.core.util.registry.Registry;
import nova.worldgen.event.WorldgenEvent;
import nova.worldgen.ore.Ore;
import nova.worldgen.world.WorldInfo;

import java.util.Optional;

/**
*
* @author ExE Boss
*/
public class WorldgenManager extends Manager<WorldgenManager> {
public final Registry<Generator> registry;

private final WorldInfo worldInfo;
private final GlobalEvents events;

public WorldgenManager(Registry<Generator> registry, GlobalEvents events, WorldInfo worldInfo) {
this.registry = registry;
this.events = events;
this.worldInfo = worldInfo;
}

public Ore register(Ore ore) {
WorldgenEvent.Register<Ore> event = new WorldgenEvent.Register<>(ore);
this.events.publish(event);
registry.register(event.generable);
return event.generable;
}

public Optional<Generator> get(String ID) {
return registry.get(ID);
}

public WorldInfo getWorldInfo() {
return this.worldInfo;
}

@Override
public void init() {
this.events.publish(new Init(this));
}

public class Init extends ManagerEvent<WorldgenManager> {
public Init(WorldgenManager manager) {
super(manager);
}
}
}
40 changes: 40 additions & 0 deletions src/main/java/nova/worldgen/event/WorldgenEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2015 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/

package nova.worldgen.event;

import nova.core.event.bus.CancelableEvent;
import nova.worldgen.generator.Generator;
import nova.worldgen.ore.Ore;

/**
*
* @author ExE Boss
*/
public abstract class WorldgenEvent extends CancelableEvent {

public static class Register<T extends Generator> extends CancelableEvent {
public T generable;

public Register(T generable) {
this.generable = generable;
}
}
}
45 changes: 45 additions & 0 deletions src/main/java/nova/worldgen/generator/CustomGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2017 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/
package nova.worldgen.generator;

import nova.core.world.World;
import nova.worldgen.WorldgenManager;
import nova.worldgen.world.WorldInfo;

import java.util.Random;

/**
* This is a black box generator.
* Unlike {@link nova.worldgen.ore.Ore},
* this one is implemented by the mod, not the game.
*
* @author ExE Boss
*/
public abstract class CustomGenerator extends Generator {

protected final WorldgenManager worldgenManager;

public CustomGenerator(String id, WorldgenManager worldgenManager) {
super(id);
this.worldgenManager = worldgenManager;
}

public abstract void generate(Random random, int chunkX, int chunkZ, double worldScale, World worlda, WorldInfo worldInfo);
}
27 changes: 27 additions & 0 deletions src/main/java/nova/worldgen/generator/Generator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nova.worldgen.generator;

import nova.core.util.Identifiable;

/**
* This class describes a structure that will be generated
* in the world by the world generator.
*
* @author ExE Boss
*/
public abstract class Generator implements Identifiable {
public final String id;

public Generator(String id) {
this.id = id;
}

@Override
public final String getID() {
return id;
}
}
Loading

0 comments on commit 69ffa52

Please sign in to comment.