Skip to content

Commit

Permalink
Major refactor of the ILoot + new gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
hube12 committed May 26, 2021
1 parent f215061 commit 3397ad2
Show file tree
Hide file tree
Showing 50 changed files with 777 additions and 246 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
gradlew text eol=lf
* text=auto

143 changes: 141 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,143 @@
# User specifics
Main.java
Test.java

# Created by https://www.toptal.com/developers/gitignore/api/intellij+all,java,gradle
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all,java,gradle

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Gradle ###
.gradle
.idea
build/
Main.java

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### Gradle Patch ###
**/build/

# End of https://www.toptal.com/developers/gitignore/api/intellij+all,java,gradle
# Ignore Gradle build output directory
build
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

The MIT License (MIT)

Copyright (c) 2020 KaptainWutax
Copyright (c) 2020 KaptainWutax, Neil

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
StructureUtils
# Feature Utils

A library to provide Structure, Feature placement as well as their generation and respective loot.

A few utilities are also present such as slime chunk, spawnpoint...

Look in the test folder for how to use

## Legal mentions
Licensed under MIT

Maintained by Neil and KaptainWutax.

NOT OFFICIAL MINECRAFT PRODUCT. NOT APPROVED BY OR ASSOCIATED WITH MOJANG.
102 changes: 92 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id "idea"
id "jacoco"
id 'org.jetbrains.kotlin.jvm' version '1.5.0-RC'
}

defaultTasks 'clean', 'test'
group = 'com.seedfinding'
archivesBaseName = project.name

defaultTasks 'clean', 'test', 'install'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}

repositories {
mavenCentral()
maven {url "https://jitpack.io"}
maven { url "https://jitpack.io" }
}

dependencies {
implementation('com.github.KaptainWutax:MathUtils:5531c4a87b0f1bb85d1dab2bdd18ce375400626a') { transitive = false }
implementation('com.github.KaptainWutax:SeedUtils:b6a383113ce5d8d09a59e91b28ff064fb97c0709') { transitive = false }
implementation('com.github.KaptainWutax:MCUtils:424f9dd6ed25672c314ab8fd2101f9634f0e2707') { transitive = false }
implementation('com.github.KaptainWutax:NoiseUtils:a3954932b15a889aa51c82176942d62f291c3b12') { transitive = false }
implementation('com.github.KaptainWutax:MCUtils:11e3c70867968877233630797741f6cd47777e41') { transitive = false }
implementation('com.github.KaptainWutax:NoiseUtils:288e1b60e0f427bead80f001d19565ad1adcbd73') { transitive = false }

implementation('com.github.KaptainWutax:BiomeUtils:43cbdbe4319790ecdfde89cc24077e8b3faf215c') {transitive = false}
implementation('com.github.KaptainWutax:TerrainUtils:21b6d72b7798403abf620f736d0f1972daf822ed') {transitive = false}
implementation('com.github.KaptainWutax:BiomeUtils:8588e0eb9f433162fe8744147f56bbbf424f25de') { transitive = false }
implementation('com.github.KaptainWutax:TerrainUtils:322c2405600be7e87ded65f7bc6f2c4f042a5472') { transitive = false }

testImplementation('com.github.KaptainWutax:ChunkRandomReversal:6b76fb5cf2cd438de56e6a46cea2a83985831834') {transitive = false}
testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.1')
testImplementation('org.junit.jupiter:junit-jupiter-params:5.7.1')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${jupiterVersion}")
testImplementation('org.junit-pioneer:junit-pioneer:1.3.8')

testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.7.1')
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}")
testRuntimeOnly('org.junit.platform:junit-platform-console:1.7.1')
}

Expand All @@ -40,6 +52,19 @@ compileTestJava {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}


compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}


test {
useJUnitPlatform {
includeEngines("junit-jupiter")
Expand All @@ -53,4 +78,61 @@ test {
showCauses true
showStackTraces true
}
finalizedBy(jacocoTestReport)
}


publishing {
publications {
mavenJava(MavenPublication) {
artifactId = "$project.name"
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = "$project.name"
description = 'An efficient library to simulate Minecraft Terrain Generation for all dimension'
url = 'http://www.kaptainwutax.seedfinding.com'
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'hube12'
name = 'Neil'
}
developer {
id = 'Kap'
name = 'KaptainWutax'
}
}
scm {
connection = 'scm:git:https://github.com/kaptainwutax/TerrainUtils.git'
url = 'https://github.com/kaptainwutax/TerrainUtils.git'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://jitpack.io/com/github/kaptainwutax/terrainutils/latest"
def snapshotsRepoUrl = "https://jitpack.io/com/github/kaptainwutax/terrainutils/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G

version=1.0.0

jupiterVersion=5.7.1
34 changes: 27 additions & 7 deletions src/main/java/kaptainwutax/featureutils/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import kaptainwutax.mcutils.rand.ChunkRand;
import kaptainwutax.mcutils.state.Dimension;
import kaptainwutax.mcutils.version.MCVersion;
import kaptainwutax.terrainutils.ChunkGenerator;

public abstract class Feature<C extends Feature.Config, D extends Feature.Data<?>> {
import kaptainwutax.terrainutils.TerrainGenerator;

public abstract class Feature<C extends Feature.Config, D extends Feature.Data<?>> implements GenerationContext {
private Context context = null;
private final C config;
private final MCVersion version;

Expand All @@ -26,17 +26,37 @@ public MCVersion getVersion() {

public abstract String getName();

public static String name(){
public static String name() {
return "unknown";
}

public abstract boolean canStart(D data, long structureSeed, ChunkRand rand);

public abstract boolean canSpawn(D data, BiomeSource source);

public abstract boolean canGenerate(D data, ChunkGenerator generator);
public abstract boolean canGenerate(D data, TerrainGenerator generator);

public boolean isValidDimension(Dimension dimension) {
return this.getValidDimension() == dimension;
}

public abstract Dimension getValidDimension();

@Override
public Context getContext(long worldSeed) {
if (this.getContext() == null) {
this.setContext(GenerationContext.super.getContext(worldSeed));
}
return this.getContext();
}

public abstract boolean isValidDimension(Dimension dimension);
public void setContext(Context context) {
this.context = context;
}

public Context getContext() {
return context;
}

public static class Config {

Expand Down Expand Up @@ -64,7 +84,7 @@ public boolean testBiome(BiomeSource source) {
}

@SuppressWarnings("unchecked")
public boolean testGenerate(ChunkGenerator generator) {
public boolean testGenerate(TerrainGenerator generator) {
return this.feature.canGenerate(this, generator);
}
}
Expand Down
Loading

0 comments on commit 3397ad2

Please sign in to comment.