From 652ba4c0a04cf86dbf693cf8536a7beace7df1cc Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 22 Dec 2016 10:24:23 +0100 Subject: [PATCH 01/17] Update to latest snapshot TODO: Wrappers --- build.gradle | 14 +++++++++----- gradle.properties | 2 +- settings.gradle | 2 +- src/main/java/nova/worldgen/ore/Ore.java | 10 ++++++---- .../nova/worldgen/ore/OreGenerationRegistry.java | 3 +-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 9d1035f..8b022d2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ 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" } @@ -8,18 +8,22 @@ plugins { apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" -dependencies novaApi("0.1.0-SNAPSHOT") +dependencies { + 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" } - "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" + } + "1_11" { + wrapper "nova.core:NOVA-Core-Wrapper-MC1.11:$nova_version" } } } diff --git a/gradle.properties b/gradle.properties index facb242..d2695d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/settings.gradle b/settings.gradle index 064e60f..5a6e2bd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,3 @@ -rootProject.name = "NOVA-WORLDGEN" +rootProject.name = "NOVA-Worldgen" include "mc17", "mc18" \ No newline at end of file diff --git a/src/main/java/nova/worldgen/ore/Ore.java b/src/main/java/nova/worldgen/ore/Ore.java index b430b2f..46982f1 100644 --- a/src/main/java/nova/worldgen/ore/Ore.java +++ b/src/main/java/nova/worldgen/ore/Ore.java @@ -1,7 +1,9 @@ package nova.worldgen.ore; import nova.core.block.BlockFactory; -import nova.core.util.Identifiable; +import nova.core.util.id.Identifiable; +import nova.core.util.id.Identifier; +import nova.core.util.id.StringIdentifier; import nova.worldgen.util.EnumSelector; /** @@ -31,7 +33,7 @@ public Ore(String oreGenName, BlockFactory block, double rarity, double clusterS } @Override - public String getID() { - return oreGenName; + public Identifier getID() { + return new StringIdentifier(oreGenName); } -} \ No newline at end of file +} diff --git a/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java b/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java index 881f4b6..8a6144d 100644 --- a/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java +++ b/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java @@ -1,7 +1,6 @@ package nova.worldgen.ore; -import nova.core.util.Registry; -import nova.worldgen.ore.Ore; +import nova.core.util.registry.Registry; public class OreGenerationRegistry extends Registry { From 983f6e0efe5100fc6ad1b8422e29eb4bd6c5f7c3 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 22 Dec 2016 10:25:45 +0100 Subject: [PATCH 02/17] Begin work on Minecraft 1.11 wrappers --- .gitignore | 4 +- build.gradle | 5 +- minecraft/.gitignore | 8 +++ minecraft/1.11/.gitignore | 17 +++++ minecraft/1.11/build.gradle | 64 +++++++++++++++++++ minecraft/1.11/gradle.properties | 10 +++ minecraft/1.7/.gitignore | 17 +++++ {mc17 => minecraft/1.7}/build.gradle | 0 {mc17 => minecraft/1.7}/gradle.properties | 1 + minecraft/1.8/.gitignore | 17 +++++ {mc18 => minecraft/1.8}/build.gradle | 0 {mc18 => minecraft/1.8}/gradle.properties | 1 + minecraft/build.gradle | 19 ++++++ settings.gradle | 4 +- .../java/nova/worldgen/WorldgenManager.java | 20 ++++++ 15 files changed, 182 insertions(+), 5 deletions(-) create mode 100644 minecraft/.gitignore create mode 100644 minecraft/1.11/.gitignore create mode 100644 minecraft/1.11/build.gradle create mode 100644 minecraft/1.11/gradle.properties create mode 100644 minecraft/1.7/.gitignore rename {mc17 => minecraft/1.7}/build.gradle (100%) rename {mc17 => minecraft/1.7}/gradle.properties (89%) create mode 100644 minecraft/1.8/.gitignore rename {mc18 => minecraft/1.8}/build.gradle (100%) rename {mc18 => minecraft/1.8}/gradle.properties (89%) create mode 100644 minecraft/build.gradle create mode 100644 src/main/java/nova/worldgen/WorldgenManager.java diff --git a/.gitignore b/.gitignore index 494a860..7e0526e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ # Sources !/src -!/mc17 -!/mc18 +!/guidelines +!/minecraft # github !/.gitignore diff --git a/build.gradle b/build.gradle index 8b022d2..24611f0 100644 --- a/build.gradle +++ b/build.gradle @@ -15,15 +15,16 @@ dependencies { nova { wrappers { "17" { - runtime project(":mc17") wrapper "nova.core:NOVA-Core-Wrapper-MC1.7:$nova_version" + runtime project(":minecraft:1.7") } "18" { - runtime project(":mc18") wrapper "nova.core:NOVA-Core-Wrapper-MC1.8:$nova_version" + runtime project(":minecraft:1.8") } "1_11" { wrapper "nova.core:NOVA-Core-Wrapper-MC1.11:$nova_version" + runtime project(":minecraft:1.11") } } } diff --git a/minecraft/.gitignore b/minecraft/.gitignore new file mode 100644 index 0000000..896c508 --- /dev/null +++ b/minecraft/.gitignore @@ -0,0 +1,8 @@ +/* + +!/build.gradle +!/.gitignore + +!/1.11 +!/1.8 +!/1.7 diff --git a/minecraft/1.11/.gitignore b/minecraft/1.11/.gitignore new file mode 100644 index 0000000..85be317 --- /dev/null +++ b/minecraft/1.11/.gitignore @@ -0,0 +1,17 @@ +# Ignore All +/* + +# Sources +!/src + +# github +!/.gitignore +!/README.md + +# gradle +!/build.gradle +!/build.properties +!/settings.gradle +!/gradle.properties +!/gradlew* +!/gradle diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle new file mode 100644 index 0000000..093b52b --- /dev/null +++ b/minecraft/1.11/build.gradle @@ -0,0 +1,64 @@ +apply plugin: "maven-publish" +apply plugin: "com.jfrog.artifactory" +apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" + +publishing { + publications { + main(MavenPublication) { + from components.java + + artifactId "NOVA-Worldgen-Wrapper-MC1.11" + + artifact sourcesJar + artifact javadocJar + + pom.withXml(writePom(project.properties)) + } + } +} + +artifactory { + publish { + defaults { + publications("main") + publishPom = true + } + } +} + +artifacts { + archives jar +} + +apply plugin: 'net.minecraftforge.gradle.forge' + +minecraft { + version = property("minecraft.version") + "-" + property("forge.version") + mappings = 'snapshot_20161111' + runDir = "run" +} + +dependencies { + compile rootProject + compile group: "nova.core", name: "NovaCore", version: property("nova_version"), changing: true + compile "nova.wrapper.mc1_11:NovaWrapper-MC1.11:0.1-SNAPSHOT:deobf" +} + +processResources { + // this will ensure that this task is redone when the versions change. + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include "mcmod.info" + + // replace version and mcversion + expand "version": project.version, "mcversion": project.minecraft.version + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude "mcmod.info" + } +} diff --git a/minecraft/1.11/gradle.properties b/minecraft/1.11/gradle.properties new file mode 100644 index 0000000..46e4de6 --- /dev/null +++ b/minecraft/1.11/gradle.properties @@ -0,0 +1,10 @@ +group = nova.wordgen + +minecraft.version = 1.11 +forge.version = 13.19.1.2189 +forgeGradleVersion = 2.2-SNAPSHOT + +packaging = jar +info.inceptionYear = 2016 +info.description = The NOVA-Minecraft Minecraft 1.8 wrapper. +info.organization.name = NOVA diff --git a/minecraft/1.7/.gitignore b/minecraft/1.7/.gitignore new file mode 100644 index 0000000..85be317 --- /dev/null +++ b/minecraft/1.7/.gitignore @@ -0,0 +1,17 @@ +# Ignore All +/* + +# Sources +!/src + +# github +!/.gitignore +!/README.md + +# gradle +!/build.gradle +!/build.properties +!/settings.gradle +!/gradle.properties +!/gradlew* +!/gradle diff --git a/mc17/build.gradle b/minecraft/1.7/build.gradle similarity index 100% rename from mc17/build.gradle rename to minecraft/1.7/build.gradle diff --git a/mc17/gradle.properties b/minecraft/1.7/gradle.properties similarity index 89% rename from mc17/gradle.properties rename to minecraft/1.7/gradle.properties index 480e6c0..213f077 100644 --- a/mc17/gradle.properties +++ b/minecraft/1.7/gradle.properties @@ -4,6 +4,7 @@ group = nova.worldgen.wrapper.mc17 nova.version = 0.1.0-SNAPSHOT minecraft.version = 1.7.10 forge.version = 10.13.4.1448-1.7.10 +forgeGradleVersion = 1.2-SNAPSHOT packaging = jar info.inceptionYear = 2015 diff --git a/minecraft/1.8/.gitignore b/minecraft/1.8/.gitignore new file mode 100644 index 0000000..85be317 --- /dev/null +++ b/minecraft/1.8/.gitignore @@ -0,0 +1,17 @@ +# Ignore All +/* + +# Sources +!/src + +# github +!/.gitignore +!/README.md + +# gradle +!/build.gradle +!/build.properties +!/settings.gradle +!/gradle.properties +!/gradlew* +!/gradle diff --git a/mc18/build.gradle b/minecraft/1.8/build.gradle similarity index 100% rename from mc18/build.gradle rename to minecraft/1.8/build.gradle diff --git a/mc18/gradle.properties b/minecraft/1.8/gradle.properties similarity index 89% rename from mc18/gradle.properties rename to minecraft/1.8/gradle.properties index 3554efd..1b407ce 100644 --- a/mc18/gradle.properties +++ b/minecraft/1.8/gradle.properties @@ -4,6 +4,7 @@ group = nova.worldgen.wrapper.mc18 nova.version = 0.1.0-SNAPSHOT minecraft.version = 1.8 forge.version = 11.14.3.1446 +forgeGradleVersion = 1.2-SNAPSHOT packaging = jar info.inceptionYear = 2015 diff --git a/minecraft/build.gradle b/minecraft/build.gradle new file mode 100644 index 0000000..905f27d --- /dev/null +++ b/minecraft/build.gradle @@ -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') + } + } +} diff --git a/settings.gradle b/settings.gradle index 5a6e2bd..aa20a86 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,5 @@ rootProject.name = "NOVA-Worldgen" -include "mc17", "mc18" \ No newline at end of file +include "minecraft:1.11" +include "minecraft:1.8" +include "minecraft:1.7" diff --git a/src/main/java/nova/worldgen/WorldgenManager.java b/src/main/java/nova/worldgen/WorldgenManager.java new file mode 100644 index 0000000..85d5294 --- /dev/null +++ b/src/main/java/nova/worldgen/WorldgenManager.java @@ -0,0 +1,20 @@ +/* + * 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; + +import nova.core.util.registry.Manager; + +/** + * + * @author ExE Boss + */ +public class WorldgenManager extends Manager { + + @Override + public void init() { + // TODO + } +} From c0b22d01f1d94c95f368b35d761370aab2fc7b9f Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 23 Dec 2016 01:48:38 +0100 Subject: [PATCH 03/17] Work on WorldManager + Add License to all files. --- src/main/java/nova/worldgen/Chunk.java | 20 ++++++++ .../java/nova/worldgen/WorldgenManager.java | 49 +++++++++++++++++-- src/main/java/nova/worldgen/ore/Ore.java | 28 +++++++++-- .../worldgen/ore/OreGenerationRegistry.java | 20 ++++++++ .../java/nova/worldgen/ore/OreHeight.java | 20 ++++++++ .../java/nova/worldgen/util/EnumSelector.java | 20 ++++++++ .../java/nova/worldgen/world/WorldInfo.java | 20 ++++++++ 7 files changed, 169 insertions(+), 8 deletions(-) diff --git a/src/main/java/nova/worldgen/Chunk.java b/src/main/java/nova/worldgen/Chunk.java index 59cfe2d..3b1c362 100644 --- a/src/main/java/nova/worldgen/Chunk.java +++ b/src/main/java/nova/worldgen/Chunk.java @@ -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 . + */ + package nova.worldgen; import nova.core.block.Block; diff --git a/src/main/java/nova/worldgen/WorldgenManager.java b/src/main/java/nova/worldgen/WorldgenManager.java index 85d5294..29e5182 100644 --- a/src/main/java/nova/worldgen/WorldgenManager.java +++ b/src/main/java/nova/worldgen/WorldgenManager.java @@ -1,20 +1,61 @@ /* - * 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. + * 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 . */ + package nova.worldgen; import nova.core.util.registry.Manager; +import nova.core.util.registry.Registry; +import nova.internal.core.Game; +import nova.worldgen.ore.Ore; +import nova.worldgen.ore.OreGenerationRegistry; + +import java.util.Optional; /** * * @author ExE Boss */ public class WorldgenManager extends Manager { + public final Registry registry; + + public WorldgenManager(OreGenerationRegistry registry) { + this.registry = registry; + } + + public Ore register(Ore ore) { + registry.register(ore); + return ore; + } + + public Optional get(String ID) { + return registry.get(ID); + } @Override public void init() { - // TODO + Game.events().publish(new Init(this)); + } + + public class Init extends ManagerEvent { + public Init(WorldgenManager manager) { + super(manager); + } } } diff --git a/src/main/java/nova/worldgen/ore/Ore.java b/src/main/java/nova/worldgen/ore/Ore.java index 46982f1..76c3095 100644 --- a/src/main/java/nova/worldgen/ore/Ore.java +++ b/src/main/java/nova/worldgen/ore/Ore.java @@ -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 . + */ + package nova.worldgen.ore; import nova.core.block.BlockFactory; @@ -11,7 +31,7 @@ * in world structure as ore. */ public final class Ore implements Identifiable { - public final String oreGenName; + public final String id; public final BlockFactory block; public final double rarity; public final double clusterSize; @@ -24,8 +44,8 @@ public final class Ore implements Identifiable { * @param clusterSize Ore cluster size multiplier, base value is 1, bigger value means bigger ore cluster * @param oreLayers World layers at which the ore can be found */ - public Ore(String oreGenName, BlockFactory block, double rarity, double clusterSize, EnumSelector oreLayers) { - this.oreGenName = oreGenName; + public Ore(String id, BlockFactory block, double rarity, double clusterSize, EnumSelector oreLayers) { + this.id = Identifiable.addPrefix(id, true); this.block = block; this.rarity = rarity; this.clusterSize = clusterSize; @@ -34,6 +54,6 @@ public Ore(String oreGenName, BlockFactory block, double rarity, double clusterS @Override public Identifier getID() { - return new StringIdentifier(oreGenName); + return new StringIdentifier(id); } } diff --git a/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java b/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java index 8a6144d..0bfc1de 100644 --- a/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java +++ b/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java @@ -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 . + */ + package nova.worldgen.ore; import nova.core.util.registry.Registry; diff --git a/src/main/java/nova/worldgen/ore/OreHeight.java b/src/main/java/nova/worldgen/ore/OreHeight.java index 479e8be..10902aa 100644 --- a/src/main/java/nova/worldgen/ore/OreHeight.java +++ b/src/main/java/nova/worldgen/ore/OreHeight.java @@ -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 . + */ + package nova.worldgen.ore; //TODO: Find better names for those diff --git a/src/main/java/nova/worldgen/util/EnumSelector.java b/src/main/java/nova/worldgen/util/EnumSelector.java index b67694f..3b86628 100644 --- a/src/main/java/nova/worldgen/util/EnumSelector.java +++ b/src/main/java/nova/worldgen/util/EnumSelector.java @@ -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 . + */ + package nova.worldgen.util; import java.util.EnumSet; diff --git a/src/main/java/nova/worldgen/world/WorldInfo.java b/src/main/java/nova/worldgen/world/WorldInfo.java index 6f28dce..eb73b76 100644 --- a/src/main/java/nova/worldgen/world/WorldInfo.java +++ b/src/main/java/nova/worldgen/world/WorldInfo.java @@ -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 . + */ + package nova.worldgen.world; import nova.core.util.shape.Cuboid; From d076ff39c45393edac0100a1492045b8f8d709ba Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 2 Jan 2017 18:42:52 +0100 Subject: [PATCH 04/17] Publish initial work on wrappers + changes to EnumSelector EnumSelector will be removed if NOVA-Team/NOVA-Core#232 is merged. --- build.gradle | 1 - minecraft/1.11/build.gradle | 6 +- minecraft/1.11/gradle.properties | 2 +- .../mc/forge/v1_11/NovaMinecraftWorldgen.java | 54 +++++++++ .../world/forward/FWWorldGenerator.java | 104 ++++++++++++++++++ minecraft/1.7/build.gradle | 7 +- .../mc/forge/v17/NovaMinecraftWorldgen.java | 53 +++++++++ .../world/forward/FWWorldGenerator.java | 102 +++++++++++++++++ minecraft/1.8/build.gradle | 4 +- minecraft/1.8/gradle.properties | 2 +- .../mc/forge/v18/NovaMinecraftWorldgen.java | 53 +++++++++ .../world/forward/FWWorldGenerator.java | 103 +++++++++++++++++ .../java/nova/worldgen/WorldgenManager.java | 7 +- .../nova/worldgen/event/WorldgenEvent.java | 38 +++++++ src/main/java/nova/worldgen/ore/Ore.java | 4 +- .../java/nova/worldgen/util/EnumSelector.java | 13 ++- 16 files changed, 533 insertions(+), 20 deletions(-) create mode 100644 minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/NovaMinecraftWorldgen.java create mode 100644 minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java create mode 100644 minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/NovaMinecraftWorldgen.java create mode 100644 minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java create mode 100644 minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/NovaMinecraftWorldgen.java create mode 100644 minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java create mode 100644 src/main/java/nova/worldgen/event/WorldgenEvent.java diff --git a/build.gradle b/build.gradle index 24611f0..88a0e43 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ plugins { id "com.jfrog.artifactory" version "3.1.1" } - apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" dependencies { diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle index 093b52b..f55c12a 100644 --- a/minecraft/1.11/build.gradle +++ b/minecraft/1.11/build.gradle @@ -34,14 +34,14 @@ apply plugin: 'net.minecraftforge.gradle.forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") - mappings = 'snapshot_20161111' + mappings = 'snapshot_20161220' runDir = "run" } dependencies { compile rootProject - compile group: "nova.core", name: "NovaCore", version: property("nova_version"), changing: true - compile "nova.wrapper.mc1_11:NovaWrapper-MC1.11:0.1-SNAPSHOT:deobf" + compile group: "nova.core", name: "NOVA-Core", version: property("nova_version"), changing: true + compile "nova.core:NOVA-Core-Wrapper-MC1.11:0.1.0-SNAPSHOT:deobf" } processResources { diff --git a/minecraft/1.11/gradle.properties b/minecraft/1.11/gradle.properties index 46e4de6..70bef15 100644 --- a/minecraft/1.11/gradle.properties +++ b/minecraft/1.11/gradle.properties @@ -6,5 +6,5 @@ forgeGradleVersion = 2.2-SNAPSHOT packaging = jar info.inceptionYear = 2016 -info.description = The NOVA-Minecraft Minecraft 1.8 wrapper. +info.description = The NOVA-Minecraft Minecraft 1.11 wrapper. info.organization.name = NOVA diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/NovaMinecraftWorldgen.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/NovaMinecraftWorldgen.java new file mode 100644 index 0000000..4f7350d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/NovaMinecraftWorldgen.java @@ -0,0 +1,54 @@ +/* + * 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 . + */ + +package nova.worldgen.wrapper.mc.forge.v1_11; + +import net.minecraftforge.fml.common.registry.GameRegistry; +import nova.core.loader.Loadable; +import nova.core.loader.Mod; +import nova.worldgen.WorldgenManager; +import nova.worldgen.wrapper.mc.forge.v1_11.wrapper.world.forward.FWWorldGenerator; + +/** + * + * @author ExE Boss + */ +@Mod(id = NovaMinecraftWorldgen.id, name = NovaMinecraftWorldgen.name, version = NovaMinecraftWorldgen.version, novaVersion = "0.0.1") +public class NovaMinecraftWorldgen implements Loadable { + + public static final String version = "0.0.1"; + public static final String id = "novaworldgen"; + public static final String name = "NOVA Worldgen"; + + public final WorldgenManager worldgenManager; + + public FWWorldGenerator worldGenerator; + + public NovaMinecraftWorldgen(WorldgenManager worldgenManager) { + this.worldgenManager = worldgenManager; + + worldGenerator = new FWWorldGenerator(worldgenManager); + } + + @Override + public void preInit() { + GameRegistry.registerWorldGenerator(worldGenerator, 0); + } +} diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java new file mode 100644 index 0000000..4da6d7d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -0,0 +1,104 @@ +/* + * 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 . + */ + +package nova.worldgen.wrapper.mc.forge.v1_11.wrapper.world.forward; + +import net.minecraft.block.Block; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkGenerator; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenMinable; +import net.minecraftforge.fml.common.IWorldGenerator; +import nova.internal.core.Game; +import nova.worldgen.WorldgenManager; +import nova.worldgen.event.WorldgenEvent; +import nova.worldgen.ore.Ore; +import nova.worldgen.ore.OreHeight; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +/** + * + * @author ExE Boss + */ +public class FWWorldGenerator implements IWorldGenerator { + + private final Map oreGen; + private final WorldgenManager worldgenManager; + + public FWWorldGenerator(WorldgenManager worldgenManager) { + this.worldgenManager = worldgenManager; + this.oreGen = new HashMap<>(); + Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block)).getDefaultState(), + (int) Math.round(evt.ore.clusterSize * 5))); + }); + } + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { + double worldScale = world.provider.getAverageGroundLevel() + 1; + Map oreHeightMap = new HashMap<>(); + this.worldgenManager.registry.stream().forEachOrdered(ore -> { + double baseCount = 12 * ore.rarity * worldScale / 64; + int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); + for(int i = 0; i < count; i++) { + oreHeightMap.clear(); + int j = 0; + + // OreHeight Values: (when worldScale == 64, which is the default) + // SURFACE = 60 (55-65) + // UNDERSURFACE = 50 (45-55) + // DEEP = 40 (35-45) + // DEEPER = 30 (25-35) + // DEEPERER = 20 (15-25) + // REALLYDEEP = 10 (5-15) + + if (ore.oreLayers.allows(OreHeight.SURFACE)) + oreHeightMap.put(j++, OreHeight.SURFACE); + if (ore.oreLayers.allows(OreHeight.UNDERSURFACE)) + oreHeightMap.put(j++, OreHeight.UNDERSURFACE); + if (ore.oreLayers.allows(OreHeight.DEEP)) + oreHeightMap.put(j++, OreHeight.DEEP); + if (ore.oreLayers.allows(OreHeight.DEEPER)) + oreHeightMap.put(j++, OreHeight.DEEPER); + if (ore.oreLayers.allows(OreHeight.DEEPERER)) + oreHeightMap.put(j++, OreHeight.DEEPERER); + if (ore.oreLayers.allows(OreHeight.REALLYDEEP)) + oreHeightMap.put(j++, OreHeight.REALLYDEEP); + if (j == 0) return; + + j = random.nextInt(oreHeightMap.size()); + OreHeight height = oreHeightMap.get(j); + + double yAdd = (OreHeight.values().length - height.ordinal() * 10 * worldScale / 64) + (5 * worldScale / 64); + + int x = chunkX + random.nextInt(16); + int y = (int) Math.round(yAdd + (random.nextDouble() * 10 * worldScale / 64)); + int z = chunkZ + random.nextInt(16); + + oreGen.get(ore).generate(world, random, new BlockPos(x, y, z)); + } + }); + } +} diff --git a/minecraft/1.7/build.gradle b/minecraft/1.7/build.gradle index e8f4a49..af2e048 100644 --- a/minecraft/1.7/build.gradle +++ b/minecraft/1.7/build.gradle @@ -17,7 +17,8 @@ buildscript { apply plugin: "maven-publish" apply plugin: "com.jfrog.artifactory" -apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" +//apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" +apply from: "../../../../.Libraries/java.gradle" publishing { publications { @@ -56,8 +57,8 @@ minecraft { dependencies { compile rootProject - compile group: "nova.core", name: "NovaCore", version: property("nova.version"), changing: true - compile "nova.wrapper.mc1710:NovaWrapper-MC1.7.10:0.1-SNAPSHOT:deobf" + compile group: "nova.core", name: "NOVA-Core", version: property("nova.version"), changing: true + compile "nova.core:NOVA-Core-Wrapper-MC1.7:0.1.0-SNAPSHOT:deobf" } processResources { diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/NovaMinecraftWorldgen.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/NovaMinecraftWorldgen.java new file mode 100644 index 0000000..641bd8d --- /dev/null +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/NovaMinecraftWorldgen.java @@ -0,0 +1,53 @@ +/* + * 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 . + */ + +package nova.worldgen.wrapper.mc.forge.v17; + +import cpw.mods.fml.common.registry.GameRegistry; +import nova.core.loader.Loadable; +import nova.core.loader.Mod; +import nova.worldgen.WorldgenManager; +import nova.worldgen.wrapper.mc.forge.v17.wrapper.world.forward.FWWorldGenerator; + +/** + * + * @author ExE Boss + */ +@Mod(id = NovaMinecraftWorldgen.id, name = NovaMinecraftWorldgen.name, version = NovaMinecraftWorldgen.version, novaVersion = "0.0.1") +public class NovaMinecraftWorldgen implements Loadable { + + public static final String version = "0.0.1"; + public static final String id = "novaworldgen"; + public static final String name = "NOVA Worldgen"; + + public final WorldgenManager worldgenManager; + + public FWWorldGenerator worldGenerator; + + public NovaMinecraftWorldgen(WorldgenManager worldgenManager) { + this.worldgenManager = worldgenManager; + } + + @Override + public void init() { + worldGenerator = new FWWorldGenerator(worldgenManager); + GameRegistry.registerWorldGenerator(worldGenerator, 0); + } +} diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java new file mode 100644 index 0000000..b60a74a --- /dev/null +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java @@ -0,0 +1,102 @@ +/* + * 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 . + */ + +package nova.worldgen.wrapper.mc.forge.v17.wrapper.world.forward; + +import cpw.mods.fml.common.IWorldGenerator; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenMinable; +import nova.internal.core.Game; +import nova.worldgen.WorldgenManager; +import nova.worldgen.event.WorldgenEvent; +import nova.worldgen.ore.Ore; +import nova.worldgen.ore.OreHeight; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +/** + * + * @author ExE Boss + */ +public class FWWorldGenerator implements IWorldGenerator { + + private final Map oreGen; + private final WorldgenManager worldgenManager; + + public FWWorldGenerator(WorldgenManager worldgenManager) { + this.worldgenManager = worldgenManager; + this.oreGen = new HashMap<>(); + Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block)), + (int) Math.round(evt.ore.clusterSize * 5))); + }); + } + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + double worldScale = world.provider.getAverageGroundLevel() + 1; + Map oreHeightMap = new HashMap<>(); + this.worldgenManager.registry.stream().forEachOrdered(ore -> { + double baseCount = 12 * ore.rarity * worldScale / 64; + int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); + for(int i = 0; i < count; i++) { + oreHeightMap.clear(); + int j = 0; + + // OreHeight Values: (when worldScale == 64) + // SURFACE = 60 (55-65) + // UNDERSURFACE = 50 (45-55) + // DEEP = 40 (35-45) + // DEEPER = 30 (25-35) + // DEEPERER = 20 (15-25) + // REALLYDEEP = 10 (5-15) + + if (ore.oreLayers.allows(OreHeight.SURFACE)) + oreHeightMap.put(j++, OreHeight.SURFACE); + if (ore.oreLayers.allows(OreHeight.UNDERSURFACE)) + oreHeightMap.put(j++, OreHeight.UNDERSURFACE); + if (ore.oreLayers.allows(OreHeight.DEEP)) + oreHeightMap.put(j++, OreHeight.DEEP); + if (ore.oreLayers.allows(OreHeight.DEEPER)) + oreHeightMap.put(j++, OreHeight.DEEPER); + if (ore.oreLayers.allows(OreHeight.DEEPERER)) + oreHeightMap.put(j++, OreHeight.DEEPERER); + if (ore.oreLayers.allows(OreHeight.REALLYDEEP)) + oreHeightMap.put(j++, OreHeight.REALLYDEEP); + if (j == 0) return; + + j = random.nextInt(oreHeightMap.size()); + OreHeight height = oreHeightMap.get(j); + + double yAdd = (OreHeight.values().length - height.ordinal() * 10 * worldScale / 64) + (5 * worldScale / 64); + + int x = chunkX + random.nextInt(16); + int y = (int) Math.round(yAdd + (random.nextDouble() * 10 * worldScale / 64)); + int z = chunkZ + random.nextInt(16); + + oreGen.get(ore).generate(world, random, x, y, z); + } + }); + } +} diff --git a/minecraft/1.8/build.gradle b/minecraft/1.8/build.gradle index bebb8fc..0720d48 100644 --- a/minecraft/1.8/build.gradle +++ b/minecraft/1.8/build.gradle @@ -57,8 +57,8 @@ minecraft { dependencies { compile rootProject - compile group: "nova.core", name: "NovaCore", version: property("nova.version"), changing: true - compile "nova.wrapper.mc18:NovaWrapper-MC1.8:0.1-SNAPSHOT:deobf" + compile group: "nova.core", name: "NOVA-Core", version: property("nova.version"), changing: true + compile "nova.core:NOVA-Core-Wrapper-MC1.8:0.1.0-SNAPSHOT:deobf" } processResources { diff --git a/minecraft/1.8/gradle.properties b/minecraft/1.8/gradle.properties index 1b407ce..7226657 100644 --- a/minecraft/1.8/gradle.properties +++ b/minecraft/1.8/gradle.properties @@ -3,7 +3,7 @@ group = nova.worldgen.wrapper.mc18 nova.version = 0.1.0-SNAPSHOT minecraft.version = 1.8 -forge.version = 11.14.3.1446 +forge.version = 11.14.3.1491 forgeGradleVersion = 1.2-SNAPSHOT packaging = jar diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/NovaMinecraftWorldgen.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/NovaMinecraftWorldgen.java new file mode 100644 index 0000000..f32c222 --- /dev/null +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/NovaMinecraftWorldgen.java @@ -0,0 +1,53 @@ +/* + * 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 . + */ + +package nova.worldgen.wrapper.mc.forge.v18; + +import net.minecraftforge.fml.common.registry.GameRegistry; +import nova.core.loader.Loadable; +import nova.core.loader.Mod; +import nova.worldgen.WorldgenManager; +import nova.worldgen.wrapper.mc.forge.v18.wrapper.world.forward.FWWorldGenerator; + +/** + * + * @author ExE Boss + */ +@Mod(id = NovaMinecraftWorldgen.id, name = NovaMinecraftWorldgen.name, version = NovaMinecraftWorldgen.version, novaVersion = "0.0.1") +public class NovaMinecraftWorldgen implements Loadable { + + public static final String version = "0.0.1"; + public static final String id = "novaworldgen"; + public static final String name = "NOVA Worldgen"; + + public final WorldgenManager worldgenManager; + + public FWWorldGenerator worldGenerator; + + public NovaMinecraftWorldgen(WorldgenManager worldgenManager) { + this.worldgenManager = worldgenManager; + } + + @Override + public void init() { + worldGenerator = new FWWorldGenerator(worldgenManager); + GameRegistry.registerWorldGenerator(worldGenerator, 0); + } +} diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java new file mode 100644 index 0000000..e8eaeeb --- /dev/null +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java @@ -0,0 +1,103 @@ +/* + * 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 . + */ + +package nova.worldgen.wrapper.mc.forge.v18.wrapper.world.forward; + +import net.minecraft.block.Block; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenMinable; +import net.minecraftforge.fml.common.IWorldGenerator; +import nova.internal.core.Game; +import nova.worldgen.WorldgenManager; +import nova.worldgen.event.WorldgenEvent; +import nova.worldgen.ore.Ore; +import nova.worldgen.ore.OreHeight; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +/** + * + * @author ExE Boss + */ +public class FWWorldGenerator implements IWorldGenerator { + + private final Map oreGen; + private final WorldgenManager worldgenManager; + + public FWWorldGenerator(WorldgenManager worldgenManager) { + this.worldgenManager = worldgenManager; + this.oreGen = new HashMap<>(); + Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block)).getDefaultState(), + (int) Math.round(evt.ore.clusterSize * 5))); + }); + } + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + double worldScale = world.provider.getAverageGroundLevel() + 1; + Map oreHeightMap = new HashMap<>(); + this.worldgenManager.registry.stream().forEachOrdered(ore -> { + double baseCount = 12 * ore.rarity * worldScale / 64; + int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); + for(int i = 0; i < count; i++) { + oreHeightMap.clear(); + int j = 0; + + // OreHeight Values: (when worldScale == 64) + // SURFACE = 60 (55-65) + // UNDERSURFACE = 50 (45-55) + // DEEP = 40 (35-45) + // DEEPER = 30 (25-35) + // DEEPERER = 20 (15-25) + // REALLYDEEP = 10 (5-15) + + if (ore.oreLayers.allows(OreHeight.SURFACE)) + oreHeightMap.put(j++, OreHeight.SURFACE); + if (ore.oreLayers.allows(OreHeight.UNDERSURFACE)) + oreHeightMap.put(j++, OreHeight.UNDERSURFACE); + if (ore.oreLayers.allows(OreHeight.DEEP)) + oreHeightMap.put(j++, OreHeight.DEEP); + if (ore.oreLayers.allows(OreHeight.DEEPER)) + oreHeightMap.put(j++, OreHeight.DEEPER); + if (ore.oreLayers.allows(OreHeight.DEEPERER)) + oreHeightMap.put(j++, OreHeight.DEEPERER); + if (ore.oreLayers.allows(OreHeight.REALLYDEEP)) + oreHeightMap.put(j++, OreHeight.REALLYDEEP); + if (j == 0) return; + + j = random.nextInt(oreHeightMap.size()); + OreHeight height = oreHeightMap.get(j); + + double yAdd = (OreHeight.values().length - height.ordinal() * 10 * worldScale / 64) + (5 * worldScale / 64); + + int x = chunkX + random.nextInt(16); + int y = (int) Math.round(yAdd + (random.nextDouble() * 10 * worldScale / 64)); + int z = chunkZ + random.nextInt(16); + + oreGen.get(ore).generate(world, random, new BlockPos(x, y, z)); + } + }); + } +} diff --git a/src/main/java/nova/worldgen/WorldgenManager.java b/src/main/java/nova/worldgen/WorldgenManager.java index 29e5182..1f0bdda 100644 --- a/src/main/java/nova/worldgen/WorldgenManager.java +++ b/src/main/java/nova/worldgen/WorldgenManager.java @@ -23,6 +23,7 @@ import nova.core.util.registry.Manager; import nova.core.util.registry.Registry; import nova.internal.core.Game; +import nova.worldgen.event.WorldgenEvent; import nova.worldgen.ore.Ore; import nova.worldgen.ore.OreGenerationRegistry; @@ -40,8 +41,10 @@ public WorldgenManager(OreGenerationRegistry registry) { } public Ore register(Ore ore) { - registry.register(ore); - return ore; + WorldgenEvent.RegisterOre event = new WorldgenEvent.RegisterOre(ore); + Game.events().publish(event); + registry.register(event.ore); + return event.ore; } public Optional get(String ID) { diff --git a/src/main/java/nova/worldgen/event/WorldgenEvent.java b/src/main/java/nova/worldgen/event/WorldgenEvent.java new file mode 100644 index 0000000..c5213f3 --- /dev/null +++ b/src/main/java/nova/worldgen/event/WorldgenEvent.java @@ -0,0 +1,38 @@ +/* + * 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 . + */ +package nova.worldgen.event; + +import nova.core.event.bus.CancelableEvent; +import nova.worldgen.ore.Ore; + +/** + * + * @author ExE Boss + */ +public abstract class WorldgenEvent extends CancelableEvent { + + public static class RegisterOre extends CancelableEvent { + public Ore ore; + + public RegisterOre(Ore ore) { + this.ore = ore; + } + } +} diff --git a/src/main/java/nova/worldgen/ore/Ore.java b/src/main/java/nova/worldgen/ore/Ore.java index 76c3095..4e1ee76 100644 --- a/src/main/java/nova/worldgen/ore/Ore.java +++ b/src/main/java/nova/worldgen/ore/Ore.java @@ -38,14 +38,14 @@ public final class Ore implements Identifiable { public final EnumSelector oreLayers; /** - * @param oreGenName Ore name in world generator, used to identify the ore + * @param id Ore name in world generator, used to identify the ore * @param block Block factory of the ore * @param rarity How rare is the ore, 1 should be considered base rarity, lower value means less common ore * @param clusterSize Ore cluster size multiplier, base value is 1, bigger value means bigger ore cluster * @param oreLayers World layers at which the ore can be found */ public Ore(String id, BlockFactory block, double rarity, double clusterSize, EnumSelector oreLayers) { - this.id = Identifiable.addPrefix(id, true); + this.id = Identifiable.addPrefix(id, false); this.block = block; this.rarity = rarity; this.clusterSize = clusterSize; diff --git a/src/main/java/nova/worldgen/util/EnumSelector.java b/src/main/java/nova/worldgen/util/EnumSelector.java index 3b86628..2c6c3eb 100644 --- a/src/main/java/nova/worldgen/util/EnumSelector.java +++ b/src/main/java/nova/worldgen/util/EnumSelector.java @@ -46,36 +46,39 @@ private void checkLocked() { throw new IllegalStateException("No edits are allowed after EnumSelector has been locked."); } - public void allowAll() { + public EnumSelector allowAll() { checkLocked(); if (!defaultBlock) defaultAllow = true; else throw new IllegalStateException("You can't allow all enum values when you are already blocking them."); + return this; } - public void blockAll() { + public EnumSelector blockAll() { checkLocked(); if (!defaultAllow) defaultBlock = true; else throw new IllegalStateException("You can't block all enum values when you are already allowing them."); + return this; } - public void apart(T value) { + public EnumSelector apart(T value) { checkLocked(); exceptions.add(value); + return this; } - public void lock() { + public EnumSelector lock() { if (defaultAllow || defaultBlock) locked = true; else throw new IllegalStateException("Cannot lock EnumSelector without specifying default behaviour."); + return this; } public boolean locked() { - return locked; } From 6fa5a981a90c94de9806c110778dac2a65e0aca9 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 3 Jan 2017 19:42:06 +0100 Subject: [PATCH 05/17] Fixed bugs in FWWorldGenerator + Switched to the EnumSelector in NOVA-Core Depends on: NOVA-Team/NOVA-Core#232 --- .../world/forward/FWWorldGenerator.java | 4 +- .../world/forward/FWWorldGenerator.java | 4 +- .../world/forward/FWWorldGenerator.java | 4 +- src/main/java/nova/worldgen/ore/Ore.java | 2 +- .../java/nova/worldgen/util/EnumSelector.java | 91 ------------------- 5 files changed, 7 insertions(+), 98 deletions(-) delete mode 100644 src/main/java/nova/worldgen/util/EnumSelector.java diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java index 4da6d7d..b9c848a 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -57,10 +57,10 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { - double worldScale = world.provider.getAverageGroundLevel() + 1; + double worldScale = world.provider.getAverageGroundLevel(); Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { - double baseCount = 12 * ore.rarity * worldScale / 64; + double baseCount = 12 / ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { oreHeightMap.clear(); diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java index b60a74a..9017403 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java @@ -55,10 +55,10 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - double worldScale = world.provider.getAverageGroundLevel() + 1; + double worldScale = world.provider.getAverageGroundLevel(); Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { - double baseCount = 12 * ore.rarity * worldScale / 64; + double baseCount = 12 / ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { oreHeightMap.clear(); diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java index e8eaeeb..8d0bc65 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java @@ -56,10 +56,10 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - double worldScale = world.provider.getAverageGroundLevel() + 1; + double worldScale = world.provider.getAverageGroundLevel(); Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { - double baseCount = 12 * ore.rarity * worldScale / 64; + double baseCount = 12 / ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { oreHeightMap.clear(); diff --git a/src/main/java/nova/worldgen/ore/Ore.java b/src/main/java/nova/worldgen/ore/Ore.java index 4e1ee76..7ecf111 100644 --- a/src/main/java/nova/worldgen/ore/Ore.java +++ b/src/main/java/nova/worldgen/ore/Ore.java @@ -21,10 +21,10 @@ package nova.worldgen.ore; import nova.core.block.BlockFactory; +import nova.core.util.EnumSelector; import nova.core.util.id.Identifiable; import nova.core.util.id.Identifier; import nova.core.util.id.StringIdentifier; -import nova.worldgen.util.EnumSelector; /** * This class describes resource that will be placed by world generator diff --git a/src/main/java/nova/worldgen/util/EnumSelector.java b/src/main/java/nova/worldgen/util/EnumSelector.java deleted file mode 100644 index 2c6c3eb..0000000 --- a/src/main/java/nova/worldgen/util/EnumSelector.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 . - */ - -package nova.worldgen.util; - -import java.util.EnumSet; - -/** - * This class is used to mark certain values from specified enum as allowed. - * Note that you must specify default state via #allowAll or #blockAll methods - * - * @param The enum - */ -public class EnumSelector> { - private EnumSet exceptions; - private boolean defaultAllow, defaultBlock = false; - private boolean locked = false; - - private EnumSelector(Class enumClass) { - exceptions = EnumSet.noneOf(enumClass); - } - - public static > EnumSelector of(Class enumClass) { - return new EnumSelector(enumClass); - } - - private void checkLocked() { - if (locked) - throw new IllegalStateException("No edits are allowed after EnumSelector has been locked."); - } - - public EnumSelector allowAll() { - checkLocked(); - if (!defaultBlock) - defaultAllow = true; - else - throw new IllegalStateException("You can't allow all enum values when you are already blocking them."); - return this; - } - - public EnumSelector blockAll() { - checkLocked(); - if (!defaultAllow) - defaultBlock = true; - else - throw new IllegalStateException("You can't block all enum values when you are already allowing them."); - return this; - } - - public EnumSelector apart(T value) { - checkLocked(); - exceptions.add(value); - return this; - } - - public EnumSelector lock() { - if (defaultAllow || defaultBlock) - locked = true; - else - throw new IllegalStateException("Cannot lock EnumSelector without specifying default behaviour."); - return this; - } - - public boolean locked() { - return locked; - } - - public boolean allows(T value) { - if (!locked) - throw new IllegalStateException("Cannot use EnumSelector that is not locked."); - else - return defaultAllow ^ exceptions.contains(value); - } -} From 6a50a6fdc016c4ff11e9e1a57df97050b6dab5a5 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 3 Jan 2017 19:44:13 +0100 Subject: [PATCH 06/17] Rolled back rarity change, as higher means more common, not less common. --- .../mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java | 2 +- .../mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java | 2 +- .../mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java index b9c848a..9569e7d 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -60,7 +60,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG double worldScale = world.provider.getAverageGroundLevel(); Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { - double baseCount = 12 / ore.rarity * worldScale / 64; + double baseCount = 12 * ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { oreHeightMap.clear(); diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java index 9017403..0629441 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java @@ -58,7 +58,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP double worldScale = world.provider.getAverageGroundLevel(); Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { - double baseCount = 12 / ore.rarity * worldScale / 64; + double baseCount = 12 * ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { oreHeightMap.clear(); diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java index 8d0bc65..734d08e 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java @@ -59,7 +59,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP double worldScale = world.provider.getAverageGroundLevel(); Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { - double baseCount = 12 / ore.rarity * worldScale / 64; + double baseCount = 12 * ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { oreHeightMap.clear(); From 188ea4fc089b7a896d124cee1ca0bcf49c293f6d Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 3 Jan 2017 20:13:53 +0100 Subject: [PATCH 07/17] Changed ore generation height into a loop + Height calculation fix --- .../world/forward/FWWorldGenerator.java | 22 ++++++++----------- .../world/forward/FWWorldGenerator.java | 22 ++++++++----------- .../world/forward/FWWorldGenerator.java | 22 ++++++++----------- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java index 9569e7d..f9cbdb7 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -33,7 +33,9 @@ import nova.worldgen.ore.Ore; import nova.worldgen.ore.OreHeight; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Random; @@ -74,24 +76,18 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG // DEEPERER = 20 (15-25) // REALLYDEEP = 10 (5-15) - if (ore.oreLayers.allows(OreHeight.SURFACE)) - oreHeightMap.put(j++, OreHeight.SURFACE); - if (ore.oreLayers.allows(OreHeight.UNDERSURFACE)) - oreHeightMap.put(j++, OreHeight.UNDERSURFACE); - if (ore.oreLayers.allows(OreHeight.DEEP)) - oreHeightMap.put(j++, OreHeight.DEEP); - if (ore.oreLayers.allows(OreHeight.DEEPER)) - oreHeightMap.put(j++, OreHeight.DEEPER); - if (ore.oreLayers.allows(OreHeight.DEEPERER)) - oreHeightMap.put(j++, OreHeight.DEEPERER); - if (ore.oreLayers.allows(OreHeight.REALLYDEEP)) - oreHeightMap.put(j++, OreHeight.REALLYDEEP); + Iterator iterator = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).iterator(); + + for (OreHeight height = iterator.next(); iterator.hasNext();) { + oreHeightMap.put(j++, height); + } + if (j == 0) return; j = random.nextInt(oreHeightMap.size()); OreHeight height = oreHeightMap.get(j); - double yAdd = (OreHeight.values().length - height.ordinal() * 10 * worldScale / 64) + (5 * worldScale / 64); + double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); int x = chunkX + random.nextInt(16); int y = (int) Math.round(yAdd + (random.nextDouble() * 10 * worldScale / 64)); diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java index 0629441..ef19c3f 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java @@ -31,7 +31,9 @@ import nova.worldgen.ore.Ore; import nova.worldgen.ore.OreHeight; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Random; @@ -72,24 +74,18 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP // DEEPERER = 20 (15-25) // REALLYDEEP = 10 (5-15) - if (ore.oreLayers.allows(OreHeight.SURFACE)) - oreHeightMap.put(j++, OreHeight.SURFACE); - if (ore.oreLayers.allows(OreHeight.UNDERSURFACE)) - oreHeightMap.put(j++, OreHeight.UNDERSURFACE); - if (ore.oreLayers.allows(OreHeight.DEEP)) - oreHeightMap.put(j++, OreHeight.DEEP); - if (ore.oreLayers.allows(OreHeight.DEEPER)) - oreHeightMap.put(j++, OreHeight.DEEPER); - if (ore.oreLayers.allows(OreHeight.DEEPERER)) - oreHeightMap.put(j++, OreHeight.DEEPERER); - if (ore.oreLayers.allows(OreHeight.REALLYDEEP)) - oreHeightMap.put(j++, OreHeight.REALLYDEEP); + Iterator iterator = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).iterator(); + + for (OreHeight height = iterator.next(); iterator.hasNext();) { + oreHeightMap.put(j++, height); + } + if (j == 0) return; j = random.nextInt(oreHeightMap.size()); OreHeight height = oreHeightMap.get(j); - double yAdd = (OreHeight.values().length - height.ordinal() * 10 * worldScale / 64) + (5 * worldScale / 64); + double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); int x = chunkX + random.nextInt(16); int y = (int) Math.round(yAdd + (random.nextDouble() * 10 * worldScale / 64)); diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java index 734d08e..e38ae03 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java @@ -32,7 +32,9 @@ import nova.worldgen.ore.Ore; import nova.worldgen.ore.OreHeight; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Random; @@ -73,24 +75,18 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP // DEEPERER = 20 (15-25) // REALLYDEEP = 10 (5-15) - if (ore.oreLayers.allows(OreHeight.SURFACE)) - oreHeightMap.put(j++, OreHeight.SURFACE); - if (ore.oreLayers.allows(OreHeight.UNDERSURFACE)) - oreHeightMap.put(j++, OreHeight.UNDERSURFACE); - if (ore.oreLayers.allows(OreHeight.DEEP)) - oreHeightMap.put(j++, OreHeight.DEEP); - if (ore.oreLayers.allows(OreHeight.DEEPER)) - oreHeightMap.put(j++, OreHeight.DEEPER); - if (ore.oreLayers.allows(OreHeight.DEEPERER)) - oreHeightMap.put(j++, OreHeight.DEEPERER); - if (ore.oreLayers.allows(OreHeight.REALLYDEEP)) - oreHeightMap.put(j++, OreHeight.REALLYDEEP); + Iterator iterator = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).iterator(); + + for (OreHeight height = iterator.next(); iterator.hasNext();) { + oreHeightMap.put(j++, height); + } + if (j == 0) return; j = random.nextInt(oreHeightMap.size()); OreHeight height = oreHeightMap.get(j); - double yAdd = (OreHeight.values().length - height.ordinal() * 10 * worldScale / 64) + (5 * worldScale / 64); + double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); int x = chunkX + random.nextInt(16); int y = (int) Math.round(yAdd + (random.nextDouble() * 10 * worldScale / 64)); From 1bc832fd0c83f2b44303a6e58415b25b8db32840 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 3 Jan 2017 21:00:05 +0100 Subject: [PATCH 08/17] Get rid of generic for loop and oreHeightMap for good --- .../world/forward/FWWorldGenerator.java | 20 ++++++------------- .../world/forward/FWWorldGenerator.java | 20 ++++++------------- .../world/forward/FWWorldGenerator.java | 20 ++++++------------- 3 files changed, 18 insertions(+), 42 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java index f9cbdb7..cfb72f0 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -35,9 +35,10 @@ import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Random; +import java.util.stream.Collectors; /** * @@ -60,14 +61,10 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { double worldScale = world.provider.getAverageGroundLevel(); - Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { double baseCount = 12 * ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { - oreHeightMap.clear(); - int j = 0; - // OreHeight Values: (when worldScale == 64, which is the default) // SURFACE = 60 (55-65) // UNDERSURFACE = 50 (45-55) @@ -76,16 +73,11 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG // DEEPERER = 20 (15-25) // REALLYDEEP = 10 (5-15) - Iterator iterator = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).iterator(); - - for (OreHeight height = iterator.next(); iterator.hasNext();) { - oreHeightMap.put(j++, height); - } - - if (j == 0) return; + List oreHeightList = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).collect(Collectors.toList()); + if (oreHeightList.isEmpty()) return; - j = random.nextInt(oreHeightMap.size()); - OreHeight height = oreHeightMap.get(j); + int j = random.nextInt(oreHeightList.size()); + OreHeight height = oreHeightList.get(j); double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java index ef19c3f..5139504 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java @@ -33,9 +33,10 @@ import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Random; +import java.util.stream.Collectors; /** * @@ -58,14 +59,10 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { double worldScale = world.provider.getAverageGroundLevel(); - Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { double baseCount = 12 * ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { - oreHeightMap.clear(); - int j = 0; - // OreHeight Values: (when worldScale == 64) // SURFACE = 60 (55-65) // UNDERSURFACE = 50 (45-55) @@ -74,16 +71,11 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP // DEEPERER = 20 (15-25) // REALLYDEEP = 10 (5-15) - Iterator iterator = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).iterator(); - - for (OreHeight height = iterator.next(); iterator.hasNext();) { - oreHeightMap.put(j++, height); - } - - if (j == 0) return; + List oreHeightList = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).collect(Collectors.toList()); + if (oreHeightList.isEmpty()) return; - j = random.nextInt(oreHeightMap.size()); - OreHeight height = oreHeightMap.get(j); + int j = random.nextInt(oreHeightList.size()); + OreHeight height = oreHeightList.get(j); double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java index e38ae03..304b1b0 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java @@ -34,9 +34,10 @@ import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Random; +import java.util.stream.Collectors; /** * @@ -59,14 +60,10 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { double worldScale = world.provider.getAverageGroundLevel(); - Map oreHeightMap = new HashMap<>(); this.worldgenManager.registry.stream().forEachOrdered(ore -> { double baseCount = 12 * ore.rarity * worldScale / 64; int count = (int) Math.round(random.nextGaussian() * Math.sqrt(baseCount) + baseCount); for(int i = 0; i < count; i++) { - oreHeightMap.clear(); - int j = 0; - // OreHeight Values: (when worldScale == 64) // SURFACE = 60 (55-65) // UNDERSURFACE = 50 (45-55) @@ -75,16 +72,11 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP // DEEPERER = 20 (15-25) // REALLYDEEP = 10 (5-15) - Iterator iterator = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).iterator(); - - for (OreHeight height = iterator.next(); iterator.hasNext();) { - oreHeightMap.put(j++, height); - } - - if (j == 0) return; + List oreHeightList = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).collect(Collectors.toList()); + if (oreHeightList.isEmpty()) return; - j = random.nextInt(oreHeightMap.size()); - OreHeight height = oreHeightMap.get(j); + int j = random.nextInt(oreHeightList.size()); + OreHeight height = oreHeightList.get(j); double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); From 7fe2de88976d2e1344aa1ec67b482c4ac4995833 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 4 Jan 2017 23:05:54 +0100 Subject: [PATCH 09/17] Move wrapper main class to proper package Reason: Consistency with already implemented wrappers --- .../NovaWorldgenWrapper.java} | 10 +++++----- .../NovaWorldgenWrapper.java} | 10 +++++----- .../NovaWorldgenWrapper.java} | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) rename minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/{NovaMinecraftWorldgen.java => launch/NovaWorldgenWrapper.java} (80%) rename minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/{NovaMinecraftWorldgen.java => launch/NovaWorldgenWrapper.java} (80%) rename minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/{NovaMinecraftWorldgen.java => launch/NovaWorldgenWrapper.java} (80%) diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/NovaMinecraftWorldgen.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java similarity index 80% rename from minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/NovaMinecraftWorldgen.java rename to minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java index 4f7350d..7de5c65 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/NovaMinecraftWorldgen.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.worldgen.wrapper.mc.forge.v1_11; +package nova.worldgen.wrapper.mc.forge.v1_11.launch; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; @@ -30,18 +30,18 @@ * * @author ExE Boss */ -@Mod(id = NovaMinecraftWorldgen.id, name = NovaMinecraftWorldgen.name, version = NovaMinecraftWorldgen.version, novaVersion = "0.0.1") -public class NovaMinecraftWorldgen implements Loadable { +@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, novaVersion = "0.0.1") +public class NovaWorldgenWrapper implements Loadable { public static final String version = "0.0.1"; - public static final String id = "novaworldgen"; + public static final String id = "nova-worldgen-wrapper"; public static final String name = "NOVA Worldgen"; public final WorldgenManager worldgenManager; public FWWorldGenerator worldGenerator; - public NovaMinecraftWorldgen(WorldgenManager worldgenManager) { + public NovaWorldgenWrapper(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; worldGenerator = new FWWorldGenerator(worldgenManager); diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/NovaMinecraftWorldgen.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java similarity index 80% rename from minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/NovaMinecraftWorldgen.java rename to minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java index 641bd8d..77ed346 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/NovaMinecraftWorldgen.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.worldgen.wrapper.mc.forge.v17; +package nova.worldgen.wrapper.mc.forge.v17.launch; import cpw.mods.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; @@ -30,18 +30,18 @@ * * @author ExE Boss */ -@Mod(id = NovaMinecraftWorldgen.id, name = NovaMinecraftWorldgen.name, version = NovaMinecraftWorldgen.version, novaVersion = "0.0.1") -public class NovaMinecraftWorldgen implements Loadable { +@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, novaVersion = "0.0.1") +public class NovaWorldgenWrapper implements Loadable { public static final String version = "0.0.1"; - public static final String id = "novaworldgen"; + public static final String id = "nova-worldgen-wrapper"; public static final String name = "NOVA Worldgen"; public final WorldgenManager worldgenManager; public FWWorldGenerator worldGenerator; - public NovaMinecraftWorldgen(WorldgenManager worldgenManager) { + public NovaWorldgenWrapper(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; } diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/NovaMinecraftWorldgen.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java similarity index 80% rename from minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/NovaMinecraftWorldgen.java rename to minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java index f32c222..7115d91 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/NovaMinecraftWorldgen.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.worldgen.wrapper.mc.forge.v18; +package nova.worldgen.wrapper.mc.forge.v18.launch; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; @@ -30,18 +30,18 @@ * * @author ExE Boss */ -@Mod(id = NovaMinecraftWorldgen.id, name = NovaMinecraftWorldgen.name, version = NovaMinecraftWorldgen.version, novaVersion = "0.0.1") -public class NovaMinecraftWorldgen implements Loadable { +@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, novaVersion = "0.0.1") +public class NovaWorldgenWrapper implements Loadable { public static final String version = "0.0.1"; - public static final String id = "novaworldgen"; + public static final String id = "nova-worldgen-wrapper"; public static final String name = "NOVA Worldgen"; public final WorldgenManager worldgenManager; public FWWorldGenerator worldGenerator; - public NovaMinecraftWorldgen(WorldgenManager worldgenManager) { + public NovaWorldgenWrapper(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; } From d284671e98e356ab8fe67bf8974ffa9b9edce1fe Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 4 Jan 2017 23:12:15 +0100 Subject: [PATCH 10/17] Get rid of local variable j in FWWorldGenerator for good --- .../forge/v1_11/wrapper/world/forward/FWWorldGenerator.java | 4 +--- .../mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java | 4 +--- .../mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java index cfb72f0..8d18c79 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -76,9 +76,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG List oreHeightList = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).collect(Collectors.toList()); if (oreHeightList.isEmpty()) return; - int j = random.nextInt(oreHeightList.size()); - OreHeight height = oreHeightList.get(j); - + OreHeight height = oreHeightList.get(random.nextInt(oreHeightList.size())); double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); int x = chunkX + random.nextInt(16); diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java index 5139504..8bb5d6d 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java @@ -74,9 +74,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP List oreHeightList = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).collect(Collectors.toList()); if (oreHeightList.isEmpty()) return; - int j = random.nextInt(oreHeightList.size()); - OreHeight height = oreHeightList.get(j); - + OreHeight height = oreHeightList.get(random.nextInt(oreHeightList.size())); double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); int x = chunkX + random.nextInt(16); diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java index 304b1b0..d69313a 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java @@ -75,9 +75,7 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP List oreHeightList = Arrays.stream(OreHeight.values()).filter(ore.oreLayers::allows).collect(Collectors.toList()); if (oreHeightList.isEmpty()) return; - int j = random.nextInt(oreHeightList.size()); - OreHeight height = oreHeightList.get(j); - + OreHeight height = oreHeightList.get(random.nextInt(oreHeightList.size())); double yAdd = (OreHeight.values().length - height.ordinal() - 1) * (10 * worldScale / 64) + (5 * worldScale / 64); int x = chunkX + random.nextInt(16); From 8a808644d9f40844a1f50b8ee41b1baf2e460d86 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 4 Jan 2017 23:52:07 +0100 Subject: [PATCH 11/17] Created Generable Reason: Worldgen is not just ores. --- src/main/java/nova/worldgen/Generable.java | 29 ++++++++++++++++++++++ src/main/java/nova/worldgen/ore/Ore.java | 17 ++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 src/main/java/nova/worldgen/Generable.java diff --git a/src/main/java/nova/worldgen/Generable.java b/src/main/java/nova/worldgen/Generable.java new file mode 100644 index 0000000..0667f9d --- /dev/null +++ b/src/main/java/nova/worldgen/Generable.java @@ -0,0 +1,29 @@ +/* + * 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; + +import nova.core.util.id.Identifiable; +import nova.core.util.id.Identifier; +import nova.core.util.id.StringIdentifier; + +/** + * This class describes a structure that will be generated + * in the world by the world generator. + * + * @author ExE Boss + */ +public abstract class Generable implements Identifiable { + public final String id; + + public Generable(String id) { + this.id = Identifiable.addPrefix(id, false); + } + + @Override + public final Identifier getID() { + return new StringIdentifier(id); + } +} diff --git a/src/main/java/nova/worldgen/ore/Ore.java b/src/main/java/nova/worldgen/ore/Ore.java index 7ecf111..eee7d22 100644 --- a/src/main/java/nova/worldgen/ore/Ore.java +++ b/src/main/java/nova/worldgen/ore/Ore.java @@ -23,15 +23,13 @@ import nova.core.block.BlockFactory; import nova.core.util.EnumSelector; import nova.core.util.id.Identifiable; -import nova.core.util.id.Identifier; -import nova.core.util.id.StringIdentifier; +import nova.worldgen.Generable; /** - * This class describes resource that will be placed by world generator - * in world structure as ore. + * This class describes a resource that will be placed in the world + * as an ore by the world generator. */ -public final class Ore implements Identifiable { - public final String id; +public final class Ore extends Generable implements Identifiable { public final BlockFactory block; public final double rarity; public final double clusterSize; @@ -45,15 +43,10 @@ public final class Ore implements Identifiable { * @param oreLayers World layers at which the ore can be found */ public Ore(String id, BlockFactory block, double rarity, double clusterSize, EnumSelector oreLayers) { - this.id = Identifiable.addPrefix(id, false); + super(id); this.block = block; this.rarity = rarity; this.clusterSize = clusterSize; this.oreLayers = oreLayers; } - - @Override - public Identifier getID() { - return new StringIdentifier(id); - } } From fa624d1c089b0006bb992a8b9182fa3842806cc7 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 5 Jan 2017 23:57:08 +0100 Subject: [PATCH 12/17] Fix dependency injection + Fix FWWorldGenerator Additional changes: OreGenerationRegistry was replaced with Registry, as it was redundant. --- .../v1_11/launch/NovaWorldgenWrapper.java | 3 ++- .../world/forward/FWWorldGenerator.java | 2 +- minecraft/1.7/build.gradle | 3 +-- .../forge/v17/launch/NovaWorldgenWrapper.java | 3 ++- .../world/forward/FWWorldGenerator.java | 2 +- .../forge/v18/launch/NovaWorldgenWrapper.java | 3 ++- .../world/forward/FWWorldGenerator.java | 2 +- .../worldgen/depmodules/WorldgenModule.java} | 18 ++++++++++++++---- src/main/java/nova/worldgen/Generable.java | 2 +- .../java/nova/worldgen/WorldgenManager.java | 3 +-- .../nova/worldgen/event/WorldgenEvent.java | 1 + .../java/nova/worldgen/world/WorldInfo.java | 7 ++++--- 12 files changed, 31 insertions(+), 18 deletions(-) rename src/main/java/nova/{worldgen/ore/OreGenerationRegistry.java => internal/worldgen/depmodules/WorldgenModule.java} (65%) diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java index 7de5c65..00de199 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java @@ -23,6 +23,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; import nova.core.loader.Mod; +import nova.internal.worldgen.depmodules.WorldgenModule; import nova.worldgen.WorldgenManager; import nova.worldgen.wrapper.mc.forge.v1_11.wrapper.world.forward.FWWorldGenerator; @@ -30,7 +31,7 @@ * * @author ExE Boss */ -@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, novaVersion = "0.0.1") +@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, modules = { WorldgenModule.class }, novaVersion = "0.0.1") public class NovaWorldgenWrapper implements Loadable { public static final String version = "0.0.1"; diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java index 8d18c79..78d7f70 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -53,7 +53,7 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; this.oreGen = new HashMap<>(); Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { - this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block)).getDefaultState(), + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())).getDefaultState(), (int) Math.round(evt.ore.clusterSize * 5))); }); } diff --git a/minecraft/1.7/build.gradle b/minecraft/1.7/build.gradle index af2e048..a626c64 100644 --- a/minecraft/1.7/build.gradle +++ b/minecraft/1.7/build.gradle @@ -17,8 +17,7 @@ buildscript { apply plugin: "maven-publish" apply plugin: "com.jfrog.artifactory" -//apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" -apply from: "../../../../.Libraries/java.gradle" +apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" publishing { publications { diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java index 77ed346..3d5a906 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java @@ -23,6 +23,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; import nova.core.loader.Mod; +import nova.internal.worldgen.depmodules.WorldgenModule; import nova.worldgen.WorldgenManager; import nova.worldgen.wrapper.mc.forge.v17.wrapper.world.forward.FWWorldGenerator; @@ -30,7 +31,7 @@ * * @author ExE Boss */ -@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, novaVersion = "0.0.1") +@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, modules = { WorldgenModule.class }, novaVersion = "0.0.1") public class NovaWorldgenWrapper implements Loadable { public static final String version = "0.0.1"; diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java index 8bb5d6d..1c589ec 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java @@ -51,7 +51,7 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; this.oreGen = new HashMap<>(); Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { - this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block)), + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())), (int) Math.round(evt.ore.clusterSize * 5))); }); } diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java index 7115d91..946b69a 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java @@ -23,6 +23,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; import nova.core.loader.Mod; +import nova.internal.worldgen.depmodules.WorldgenModule; import nova.worldgen.WorldgenManager; import nova.worldgen.wrapper.mc.forge.v18.wrapper.world.forward.FWWorldGenerator; @@ -30,7 +31,7 @@ * * @author ExE Boss */ -@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, novaVersion = "0.0.1") +@Mod(id = NovaWorldgenWrapper.id, name = NovaWorldgenWrapper.name, version = NovaWorldgenWrapper.version, modules = { WorldgenModule.class }, novaVersion = "0.0.1") public class NovaWorldgenWrapper implements Loadable { public static final String version = "0.0.1"; diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java index d69313a..07383d1 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java @@ -52,7 +52,7 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; this.oreGen = new HashMap<>(); Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { - this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block)).getDefaultState(), + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())).getDefaultState(), (int) Math.round(evt.ore.clusterSize * 5))); }); } diff --git a/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java b/src/main/java/nova/internal/worldgen/depmodules/WorldgenModule.java similarity index 65% rename from src/main/java/nova/worldgen/ore/OreGenerationRegistry.java rename to src/main/java/nova/internal/worldgen/depmodules/WorldgenModule.java index 0bfc1de..dac85fe 100644 --- a/src/main/java/nova/worldgen/ore/OreGenerationRegistry.java +++ b/src/main/java/nova/internal/worldgen/depmodules/WorldgenModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 NOVA, All rights reserved. + * 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. @@ -18,10 +18,20 @@ * along with NOVA. If not, see . */ -package nova.worldgen.ore; +package nova.internal.worldgen.depmodules; -import nova.core.util.registry.Registry; +import nova.worldgen.WorldgenManager; +import se.jbee.inject.bind.BinderModule; +import se.jbee.inject.util.Scoped; -public class OreGenerationRegistry extends Registry { +/** + * + * @author ExE Boss + */ +public class WorldgenModule extends BinderModule { + @Override + protected void declare() { + per(Scoped.APPLICATION).bind(WorldgenManager.class).toConstructor(); + } } diff --git a/src/main/java/nova/worldgen/Generable.java b/src/main/java/nova/worldgen/Generable.java index 0667f9d..00a2abd 100644 --- a/src/main/java/nova/worldgen/Generable.java +++ b/src/main/java/nova/worldgen/Generable.java @@ -19,7 +19,7 @@ public abstract class Generable implements Identifiable { public final String id; public Generable(String id) { - this.id = Identifiable.addPrefix(id, false); + this.id = id; } @Override diff --git a/src/main/java/nova/worldgen/WorldgenManager.java b/src/main/java/nova/worldgen/WorldgenManager.java index 1f0bdda..59b59e1 100644 --- a/src/main/java/nova/worldgen/WorldgenManager.java +++ b/src/main/java/nova/worldgen/WorldgenManager.java @@ -25,7 +25,6 @@ import nova.internal.core.Game; import nova.worldgen.event.WorldgenEvent; import nova.worldgen.ore.Ore; -import nova.worldgen.ore.OreGenerationRegistry; import java.util.Optional; @@ -36,7 +35,7 @@ public class WorldgenManager extends Manager { public final Registry registry; - public WorldgenManager(OreGenerationRegistry registry) { + public WorldgenManager(Registry registry) { this.registry = registry; } diff --git a/src/main/java/nova/worldgen/event/WorldgenEvent.java b/src/main/java/nova/worldgen/event/WorldgenEvent.java index c5213f3..5d1da28 100644 --- a/src/main/java/nova/worldgen/event/WorldgenEvent.java +++ b/src/main/java/nova/worldgen/event/WorldgenEvent.java @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with NOVA. If not, see . */ + package nova.worldgen.event; import nova.core.event.bus.CancelableEvent; diff --git a/src/main/java/nova/worldgen/world/WorldInfo.java b/src/main/java/nova/worldgen/world/WorldInfo.java index eb73b76..904692c 100644 --- a/src/main/java/nova/worldgen/world/WorldInfo.java +++ b/src/main/java/nova/worldgen/world/WorldInfo.java @@ -20,11 +20,12 @@ package nova.worldgen.world; +import nova.core.util.registry.Registry; import nova.core.util.shape.Cuboid; -import nova.worldgen.ore.OreGenerationRegistry; +import nova.worldgen.ore.Ore; /** - * This class profides information on world that world generator may need + * This class provides information on world that world generator may need */ public abstract class WorldInfo { /** @@ -40,5 +41,5 @@ public abstract class WorldInfo { /** * @return {@link OreGenerationRegistry} for the world */ - public abstract OreGenerationRegistry getOreGenerationRegistry(); + public abstract Registry getOreGenerationRegistry(); } From 534bb03ffcc217f12e6ea299b4409de0aac361a5 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 6 Jan 2017 20:43:28 +0100 Subject: [PATCH 13/17] Build script fixes --- minecraft/1.11/build.gradle | 2 +- minecraft/1.7/build.gradle | 4 ++-- minecraft/1.8/build.gradle | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle index f55c12a..9a9f6e5 100644 --- a/minecraft/1.11/build.gradle +++ b/minecraft/1.11/build.gradle @@ -41,7 +41,7 @@ minecraft { dependencies { compile rootProject compile group: "nova.core", name: "NOVA-Core", version: property("nova_version"), changing: true - compile "nova.core:NOVA-Core-Wrapper-MC1.11:0.1.0-SNAPSHOT:deobf" + compile group: "nova.core", name: "NOVA-Core-Wrapper-MC1.11", version: property("nova_version"), classifier: "deobf", changing: true } processResources { diff --git a/minecraft/1.7/build.gradle b/minecraft/1.7/build.gradle index a626c64..31dc459 100644 --- a/minecraft/1.7/build.gradle +++ b/minecraft/1.7/build.gradle @@ -56,8 +56,8 @@ minecraft { dependencies { compile rootProject - compile group: "nova.core", name: "NOVA-Core", version: property("nova.version"), changing: true - compile "nova.core:NOVA-Core-Wrapper-MC1.7:0.1.0-SNAPSHOT:deobf" + compile group: "nova.core", name: "NOVA-Core", version: property("nova_version"), changing: true + compile group: "nova.core", name: "NOVA-Core-Wrapper-MC1.7", version: property("nova_version"), classifier: "deobf", changing: true } processResources { diff --git a/minecraft/1.8/build.gradle b/minecraft/1.8/build.gradle index 0720d48..c679b19 100644 --- a/minecraft/1.8/build.gradle +++ b/minecraft/1.8/build.gradle @@ -57,8 +57,8 @@ minecraft { dependencies { compile rootProject - compile group: "nova.core", name: "NOVA-Core", version: property("nova.version"), changing: true - compile "nova.core:NOVA-Core-Wrapper-MC1.8:0.1.0-SNAPSHOT:deobf" + compile group: "nova.core", name: "NOVA-Core", version: property("nova_version"), changing: true + compile group: "nova.core", name: "NOVA-Core-Wrapper-MC1.8", version: property("nova_version"), classifier: "deobf", changing: true } processResources { From 54a94b8218c413e24ad63868cfc5e93f43b76c82 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 11 Jan 2017 03:10:25 +0100 Subject: [PATCH 14/17] Remove dependency on NOVA-Team/NOVA-Core#227 + Build script fixes --- build.gradle | 2 +- minecraft/1.11/gradle.properties | 4 +--- minecraft/1.7/gradle.properties | 4 ---- minecraft/1.8/gradle.properties | 4 ---- src/main/java/nova/worldgen/Generable.java | 8 +++----- src/main/java/nova/worldgen/ore/Ore.java | 3 +-- 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index 88a0e43..6bfade8 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" dependencies { - nova(nova_version) + compile nova(nova_version) } nova { diff --git a/minecraft/1.11/gradle.properties b/minecraft/1.11/gradle.properties index 70bef15..160c5b2 100644 --- a/minecraft/1.11/gradle.properties +++ b/minecraft/1.11/gradle.properties @@ -1,10 +1,8 @@ -group = nova.wordgen - minecraft.version = 1.11 forge.version = 13.19.1.2189 forgeGradleVersion = 2.2-SNAPSHOT packaging = jar info.inceptionYear = 2016 -info.description = The NOVA-Minecraft Minecraft 1.11 wrapper. +info.description = The NOVA-Worldgen Minecraft 1.11 wrapper. info.organization.name = NOVA diff --git a/minecraft/1.7/gradle.properties b/minecraft/1.7/gradle.properties index 213f077..1ab3696 100644 --- a/minecraft/1.7/gradle.properties +++ b/minecraft/1.7/gradle.properties @@ -1,7 +1,3 @@ -version = 0.0.1-SNAPSHOT -group = nova.worldgen.wrapper.mc17 - -nova.version = 0.1.0-SNAPSHOT minecraft.version = 1.7.10 forge.version = 10.13.4.1448-1.7.10 forgeGradleVersion = 1.2-SNAPSHOT diff --git a/minecraft/1.8/gradle.properties b/minecraft/1.8/gradle.properties index 7226657..ac2a829 100644 --- a/minecraft/1.8/gradle.properties +++ b/minecraft/1.8/gradle.properties @@ -1,7 +1,3 @@ -version = 0.0.1-SNAPSHOT -group = nova.worldgen.wrapper.mc18 - -nova.version = 0.1.0-SNAPSHOT minecraft.version = 1.8 forge.version = 11.14.3.1491 forgeGradleVersion = 1.2-SNAPSHOT diff --git a/src/main/java/nova/worldgen/Generable.java b/src/main/java/nova/worldgen/Generable.java index 00a2abd..789145b 100644 --- a/src/main/java/nova/worldgen/Generable.java +++ b/src/main/java/nova/worldgen/Generable.java @@ -5,9 +5,7 @@ */ package nova.worldgen; -import nova.core.util.id.Identifiable; -import nova.core.util.id.Identifier; -import nova.core.util.id.StringIdentifier; +import nova.core.util.Identifiable; /** * This class describes a structure that will be generated @@ -23,7 +21,7 @@ public Generable(String id) { } @Override - public final Identifier getID() { - return new StringIdentifier(id); + public final String getID() { + return id; } } diff --git a/src/main/java/nova/worldgen/ore/Ore.java b/src/main/java/nova/worldgen/ore/Ore.java index eee7d22..8e86cf7 100644 --- a/src/main/java/nova/worldgen/ore/Ore.java +++ b/src/main/java/nova/worldgen/ore/Ore.java @@ -22,14 +22,13 @@ import nova.core.block.BlockFactory; import nova.core.util.EnumSelector; -import nova.core.util.id.Identifiable; import nova.worldgen.Generable; /** * This class describes a resource that will be placed in the world * as an ore by the world generator. */ -public final class Ore extends Generable implements Identifiable { +public final class Ore extends Generable { public final BlockFactory block; public final double rarity; public final double clusterSize; From eb26cfa239f26cb498d3f93609e5bf9547244d7a Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sat, 14 Jan 2017 17:43:35 +0100 Subject: [PATCH 15/17] Package fixes --- .../mc/forge/{v17 => v1_7_10}/launch/NovaWorldgenWrapper.java | 4 ++-- .../wrapper/world/forward/FWWorldGenerator.java | 2 +- .../mc/forge/{v18 => v1_8}/launch/NovaWorldgenWrapper.java | 4 ++-- .../{v18 => v1_8}/wrapper/world/forward/FWWorldGenerator.java | 2 +- src/main/java/nova/worldgen/WorldgenManager.java | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/{v17 => v1_7_10}/launch/NovaWorldgenWrapper.java (92%) rename minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/{v17 => v1_7_10}/wrapper/world/forward/FWWorldGenerator.java (97%) rename minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/{v18 => v1_8}/launch/NovaWorldgenWrapper.java (92%) rename minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/{v18 => v1_8}/wrapper/world/forward/FWWorldGenerator.java (98%) diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java similarity index 92% rename from minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java rename to minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java index 3d5a906..ec18f77 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java @@ -18,14 +18,14 @@ * along with NOVA. If not, see . */ -package nova.worldgen.wrapper.mc.forge.v17.launch; +package nova.worldgen.wrapper.mc.forge.v1_7_10.launch; import cpw.mods.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; import nova.core.loader.Mod; import nova.internal.worldgen.depmodules.WorldgenModule; import nova.worldgen.WorldgenManager; -import nova.worldgen.wrapper.mc.forge.v17.wrapper.world.forward.FWWorldGenerator; +import nova.worldgen.wrapper.mc.forge.v1_7_10.wrapper.world.forward.FWWorldGenerator; /** * diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/wrapper/world/forward/FWWorldGenerator.java similarity index 97% rename from minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java rename to minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/wrapper/world/forward/FWWorldGenerator.java index 1c589ec..af11561 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v17/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/wrapper/world/forward/FWWorldGenerator.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.worldgen.wrapper.mc.forge.v17.wrapper.world.forward; +package nova.worldgen.wrapper.mc.forge.v1_7_10.wrapper.world.forward; import cpw.mods.fml.common.IWorldGenerator; import net.minecraft.block.Block; diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/launch/NovaWorldgenWrapper.java similarity index 92% rename from minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java rename to minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/launch/NovaWorldgenWrapper.java index 946b69a..34e2874 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/launch/NovaWorldgenWrapper.java @@ -18,14 +18,14 @@ * along with NOVA. If not, see . */ -package nova.worldgen.wrapper.mc.forge.v18.launch; +package nova.worldgen.wrapper.mc.forge.v1_8.launch; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.loader.Loadable; import nova.core.loader.Mod; import nova.internal.worldgen.depmodules.WorldgenModule; import nova.worldgen.WorldgenManager; -import nova.worldgen.wrapper.mc.forge.v18.wrapper.world.forward.FWWorldGenerator; +import nova.worldgen.wrapper.mc.forge.v1_8.wrapper.world.forward.FWWorldGenerator; /** * diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/wrapper/world/forward/FWWorldGenerator.java similarity index 98% rename from minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java rename to minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/wrapper/world/forward/FWWorldGenerator.java index 07383d1..d5cff4d 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v18/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/wrapper/world/forward/FWWorldGenerator.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.worldgen.wrapper.mc.forge.v18.wrapper.world.forward; +package nova.worldgen.wrapper.mc.forge.v1_8.wrapper.world.forward; import net.minecraft.block.Block; import net.minecraft.util.BlockPos; diff --git a/src/main/java/nova/worldgen/WorldgenManager.java b/src/main/java/nova/worldgen/WorldgenManager.java index 59b59e1..6e54fcb 100644 --- a/src/main/java/nova/worldgen/WorldgenManager.java +++ b/src/main/java/nova/worldgen/WorldgenManager.java @@ -35,8 +35,8 @@ public class WorldgenManager extends Manager { public final Registry registry; - public WorldgenManager(Registry registry) { - this.registry = registry; + public WorldgenManager() { + this.registry = new Registry<>(); } public Ore register(Ore ore) { From b300109dea0823214ec950383e961278008eaea2 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sat, 14 Jan 2017 18:18:59 +0100 Subject: [PATCH 16/17] More fixes --- minecraft/1.7/build.gradle | 2 +- .../mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java | 6 +++--- .../wrapper/world/forward/FWWorldGenerator.java | 3 +-- minecraft/1.8/build.gradle | 2 +- .../mc/forge/v1_8/launch/NovaWorldgenWrapper.java | 6 +++--- .../v1_8/wrapper/world/forward/FWWorldGenerator.java | 3 +-- src/main/java/nova/worldgen/WorldgenManager.java | 11 +++++++---- src/main/java/nova/worldgen/world/WorldInfo.java | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/minecraft/1.7/build.gradle b/minecraft/1.7/build.gradle index 31dc459..7cd5aee 100644 --- a/minecraft/1.7/build.gradle +++ b/minecraft/1.7/build.gradle @@ -24,7 +24,7 @@ publishing { main(MavenPublication) { from components.java - artifactId "NovaWorldgen-Wrapper-MC1.7.10" + artifactId "NOVA-Worldgen-Wrapper-MC1.7.10" artifact sourcesJar artifact javadocJar diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java index ec18f77..bd1e3b6 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/launch/NovaWorldgenWrapper.java @@ -44,11 +44,11 @@ public class NovaWorldgenWrapper implements Loadable { public NovaWorldgenWrapper(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; + this.worldGenerator = new FWWorldGenerator(this.worldgenManager); } @Override - public void init() { - worldGenerator = new FWWorldGenerator(worldgenManager); - GameRegistry.registerWorldGenerator(worldGenerator, 0); + public void preInit() { + GameRegistry.registerWorldGenerator(this.worldGenerator, 0); } } diff --git a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/wrapper/world/forward/FWWorldGenerator.java index af11561..071081e 100644 --- a/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.7/src/main/java/nova/worldgen/wrapper/mc/forge/v1_7_10/wrapper/world/forward/FWWorldGenerator.java @@ -51,8 +51,7 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; this.oreGen = new HashMap<>(); Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { - this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())), - (int) Math.round(evt.ore.clusterSize * 5))); + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())), (int) Math.round(evt.ore.clusterSize * 5))); }); } diff --git a/minecraft/1.8/build.gradle b/minecraft/1.8/build.gradle index c679b19..51f6204 100644 --- a/minecraft/1.8/build.gradle +++ b/minecraft/1.8/build.gradle @@ -24,7 +24,7 @@ publishing { main(MavenPublication) { from components.java - artifactId "NovaWorldgen-Wrapper-MC1.8" + artifactId "NOVA-Worldgen-Wrapper-MC1.8" artifact sourcesJar artifact javadocJar diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/launch/NovaWorldgenWrapper.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/launch/NovaWorldgenWrapper.java index 34e2874..35e1cc4 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/launch/NovaWorldgenWrapper.java @@ -44,11 +44,11 @@ public class NovaWorldgenWrapper implements Loadable { public NovaWorldgenWrapper(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; + this.worldGenerator = new FWWorldGenerator(this.worldgenManager); } @Override - public void init() { - worldGenerator = new FWWorldGenerator(worldgenManager); - GameRegistry.registerWorldGenerator(worldGenerator, 0); + public void preInit() { + GameRegistry.registerWorldGenerator(this.worldGenerator, 0); } } diff --git a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/wrapper/world/forward/FWWorldGenerator.java index d5cff4d..28603c3 100644 --- a/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.8/src/main/java/nova/worldgen/wrapper/mc/forge/v1_8/wrapper/world/forward/FWWorldGenerator.java @@ -52,8 +52,7 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; this.oreGen = new HashMap<>(); Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { - this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())).getDefaultState(), - (int) Math.round(evt.ore.clusterSize * 5))); + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())).getDefaultState(), (int) Math.round(evt.ore.clusterSize * 5))); }); } diff --git a/src/main/java/nova/worldgen/WorldgenManager.java b/src/main/java/nova/worldgen/WorldgenManager.java index 6e54fcb..7f5c484 100644 --- a/src/main/java/nova/worldgen/WorldgenManager.java +++ b/src/main/java/nova/worldgen/WorldgenManager.java @@ -20,9 +20,9 @@ package nova.worldgen; +import nova.core.event.bus.GlobalEvents; import nova.core.util.registry.Manager; import nova.core.util.registry.Registry; -import nova.internal.core.Game; import nova.worldgen.event.WorldgenEvent; import nova.worldgen.ore.Ore; @@ -35,13 +35,16 @@ public class WorldgenManager extends Manager { public final Registry registry; - public WorldgenManager() { + private final GlobalEvents events; + + public WorldgenManager(GlobalEvents events) { this.registry = new Registry<>(); + this.events = events; } public Ore register(Ore ore) { WorldgenEvent.RegisterOre event = new WorldgenEvent.RegisterOre(ore); - Game.events().publish(event); + this.events.publish(event); registry.register(event.ore); return event.ore; } @@ -52,7 +55,7 @@ public Optional get(String ID) { @Override public void init() { - Game.events().publish(new Init(this)); + this.events.publish(new Init(this)); } public class Init extends ManagerEvent { diff --git a/src/main/java/nova/worldgen/world/WorldInfo.java b/src/main/java/nova/worldgen/world/WorldInfo.java index 904692c..90184f0 100644 --- a/src/main/java/nova/worldgen/world/WorldInfo.java +++ b/src/main/java/nova/worldgen/world/WorldInfo.java @@ -39,7 +39,7 @@ public abstract class WorldInfo { public abstract Cuboid getWorldGenerationUnitDimmensions(); /** - * @return {@link OreGenerationRegistry} for the world + * @return {@link Registry}{@code <}{@link Ore}{@code >} for the world */ public abstract Registry getOreGenerationRegistry(); } From 07414df86b4036ed63bda55535c71fe3b71c2b65 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sat, 14 Jan 2017 19:10:10 +0100 Subject: [PATCH 17/17] More fixes (1.11) --- .../wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java | 5 ++--- .../forge/v1_11/wrapper/world/forward/FWWorldGenerator.java | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java index 00de199..c21fd42 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/launch/NovaWorldgenWrapper.java @@ -44,12 +44,11 @@ public class NovaWorldgenWrapper implements Loadable { public NovaWorldgenWrapper(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; - - worldGenerator = new FWWorldGenerator(worldgenManager); + this.worldGenerator = new FWWorldGenerator(this.worldgenManager); } @Override public void preInit() { - GameRegistry.registerWorldGenerator(worldGenerator, 0); + GameRegistry.registerWorldGenerator(this.worldGenerator, 0); } } diff --git a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java index 78d7f70..295a851 100644 --- a/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java +++ b/minecraft/1.11/src/main/java/nova/worldgen/wrapper/mc/forge/v1_11/wrapper/world/forward/FWWorldGenerator.java @@ -53,8 +53,7 @@ public FWWorldGenerator(WorldgenManager worldgenManager) { this.worldgenManager = worldgenManager; this.oreGen = new HashMap<>(); Game.events().on(WorldgenEvent.RegisterOre.class).bind(evt -> { - this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())).getDefaultState(), - (int) Math.round(evt.ore.clusterSize * 5))); + this.oreGen.put(evt.ore, new WorldGenMinable(((Block)Game.natives().toNative(evt.ore.block.build())).getDefaultState(), (int) Math.round(evt.ore.clusterSize * 5))); }); }