From 3397ad245e9725ca4cb9c0724b2bdbf67ea9640d Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 26 May 2021 23:53:47 +0200 Subject: [PATCH] Major refactor of the ILoot + new gradle --- .gitattributes | 8 + .gitignore | 143 +++++++++++++++++- LICENSE.md | 2 +- README.md | 15 +- build.gradle | 102 +++++++++++-- gradle.properties | 6 + .../kaptainwutax/featureutils/Feature.java | 34 ++++- .../featureutils/GenerationContext.java | 73 +++++++++ .../featureutils/decorator/DesertWell.java | 8 +- .../featureutils/decorator/EndGateway.java | 8 +- .../featureutils/loot/ChestContent.java | 107 +++++++++++++ .../kaptainwutax/featureutils/loot/ILoot.java | 79 +++++++--- .../featureutils/misc/SlimeChunk.java | 8 +- .../structure/BastionRemnant.java | 4 +- .../structure/BuriedTreasure.java | 4 +- .../featureutils/structure/DesertPyramid.java | 4 +- .../featureutils/structure/EndCity.java | 10 +- .../featureutils/structure/Fortress.java | 4 +- .../featureutils/structure/Igloo.java | 4 +- .../featureutils/structure/JunglePyramid.java | 4 +- .../featureutils/structure/Mansion.java | 4 +- .../featureutils/structure/Mineshaft.java | 4 +- .../featureutils/structure/Monument.java | 4 +- .../featureutils/structure/NetherFossil.java | 8 +- .../featureutils/structure/OceanRuin.java | 4 +- .../structure/PillagerOutpost.java | 4 +- .../featureutils/structure/RuinedPortal.java | 16 +- .../featureutils/structure/Shipwreck.java | 4 +- .../featureutils/structure/Stronghold.java | 4 +- .../featureutils/structure/Structure.java | 10 +- .../featureutils/structure/SwampHut.java | 4 +- .../featureutils/structure/Village.java | 4 +- .../structure/generator/Generator.java | 14 +- .../structure/generator/Generators.java | 1 + .../structure/BuriedTreasureGenerator.java | 17 ++- .../structure/DesertPyramidGenerator.java | 24 ++- .../generator/structure/EndCityGenerator.java | 60 +++++--- .../structure/FortressGenerator.java | 6 +- .../structure/RuinedPortalGenerator.java | 67 ++++---- .../structure/ShipwreckGenerator.java | 25 ++- .../structure/StrongholdGenerator.java | 4 +- .../generator/structure/VillageGenerator.java | 4 +- .../examples/loot/explanation/LootTest.java | 4 - .../LootTestForwardGoldenApple.java | 8 +- .../examples/loot/simple/GetLoot.java | 44 +++--- .../loot/LootTestBuriedTreasure.java | 8 +- .../loot/LootTestDesertTemple.java | 8 +- .../featureutils/loot/LootTestEndCity.java | 12 +- .../loot/LootTestRuinedPortal.java | 10 +- .../featureutils/loot/LootTestShipwreck.java | 10 +- 50 files changed, 777 insertions(+), 246 deletions(-) create mode 100644 .gitattributes create mode 100644 gradle.properties create mode 100644 src/main/java/kaptainwutax/featureutils/GenerationContext.java create mode 100644 src/main/java/kaptainwutax/featureutils/loot/ChestContent.java diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ac98962 --- /dev/null +++ b/.gitattributes @@ -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 + diff --git a/.gitignore b/.gitignore index 3e2c8f8..8f00502 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file + +# 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 diff --git a/LICENSE.md b/LICENSE.md index 3b57ff6..43ab7f4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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 diff --git a/README.md b/README.md index 9b58fc7..fd532a8 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build.gradle b/build.gradle index 46b7e7e..df4d855 100644 --- a/build.gradle +++ b/build.gradle @@ -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') } @@ -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") @@ -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) + } } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..268adb9 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,6 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx4G + +version=1.0.0 + +jupiterVersion=5.7.1 diff --git a/src/main/java/kaptainwutax/featureutils/Feature.java b/src/main/java/kaptainwutax/featureutils/Feature.java index 1d6dcc7..c0100b7 100644 --- a/src/main/java/kaptainwutax/featureutils/Feature.java +++ b/src/main/java/kaptainwutax/featureutils/Feature.java @@ -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> { +import kaptainwutax.terrainutils.TerrainGenerator; +public abstract class Feature> implements GenerationContext { + private Context context = null; private final C config; private final MCVersion version; @@ -26,7 +26,7 @@ public MCVersion getVersion() { public abstract String getName(); - public static String name(){ + public static String name() { return "unknown"; } @@ -34,9 +34,29 @@ public static String name(){ 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 { @@ -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); } } diff --git a/src/main/java/kaptainwutax/featureutils/GenerationContext.java b/src/main/java/kaptainwutax/featureutils/GenerationContext.java new file mode 100644 index 0000000..c30e60c --- /dev/null +++ b/src/main/java/kaptainwutax/featureutils/GenerationContext.java @@ -0,0 +1,73 @@ +package kaptainwutax.featureutils; + +import kaptainwutax.biomeutils.source.BiomeSource; +import kaptainwutax.mcutils.state.Dimension; +import kaptainwutax.mcutils.version.MCVersion; +import kaptainwutax.mcutils.version.UnsupportedVersion; +import kaptainwutax.terrainutils.TerrainGenerator; + +/** + * Useful utility to bind a context to any class, gives a biome source and a terrain generator, mainly implemented for Features + */ +public interface GenerationContext { + default Context getContext(long worldSeed) { + if (!(this instanceof Feature)) return null; + Feature feature = (Feature) this; + BiomeSource biomeSource = BiomeSource.of(feature.getValidDimension(), feature.getVersion(), worldSeed); + TerrainGenerator generator = null; + if (biomeSource != null) { + try { + generator = TerrainGenerator.of(feature.getValidDimension(), biomeSource); + } catch (UnsupportedVersion ignored) {} + } + + return new Context(biomeSource, generator); + } + + default Context getContext(long worldSeed, Dimension dimension, MCVersion version) { + BiomeSource biomeSource = BiomeSource.of(dimension, version, worldSeed); + TerrainGenerator generator = null; + if (biomeSource != null) { + try { + generator = TerrainGenerator.of(biomeSource); + } catch (UnsupportedVersion ignored) {} + } + + return new Context(biomeSource, generator); + } + + class Context { + private final BiomeSource biomeSource; + private final TerrainGenerator generator; + private final Long worldSeed; + private final Dimension dimension; + + public Context(BiomeSource biomeSource, TerrainGenerator generator) { + this.biomeSource = biomeSource; + this.generator = generator; + if (biomeSource != null) { + this.worldSeed = biomeSource.getWorldSeed(); + this.dimension = biomeSource.getDimension(); + } else { + this.worldSeed = null; + this.dimension = null; + } + } + + public Dimension getDimension() { + return dimension; + } + + public BiomeSource getBiomeSource() { + return biomeSource; + } + + public TerrainGenerator getGenerator() { + return generator; + } + + public Long getWorldSeed() { + return worldSeed; + } + } +} diff --git a/src/main/java/kaptainwutax/featureutils/decorator/DesertWell.java b/src/main/java/kaptainwutax/featureutils/decorator/DesertWell.java index b5bf6da..84e3455 100644 --- a/src/main/java/kaptainwutax/featureutils/decorator/DesertWell.java +++ b/src/main/java/kaptainwutax/featureutils/decorator/DesertWell.java @@ -6,7 +6,7 @@ import kaptainwutax.mcutils.state.Dimension; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; public class DesertWell extends BiomelessDecorator { @@ -45,13 +45,13 @@ public boolean canStart(DesertWell.Data data, long structureSeed, ChunkRand rand } @Override - public boolean canGenerate(Data data, ChunkGenerator generator) { + public boolean canGenerate(Data data, TerrainGenerator generator) { return true; } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/decorator/EndGateway.java b/src/main/java/kaptainwutax/featureutils/decorator/EndGateway.java index e593817..0463f0d 100644 --- a/src/main/java/kaptainwutax/featureutils/decorator/EndGateway.java +++ b/src/main/java/kaptainwutax/featureutils/decorator/EndGateway.java @@ -6,7 +6,7 @@ import kaptainwutax.mcutils.state.Dimension; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; public class EndGateway extends BiomelessDecorator { @@ -46,13 +46,13 @@ public boolean canStart(EndGateway.Data data, long structureSeed, ChunkRand rand } @Override - public boolean canGenerate(Data data, ChunkGenerator generator) { + public boolean canGenerate(Data data, TerrainGenerator generator) { return true; } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.END; + public Dimension getValidDimension() { + return Dimension.END; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/loot/ChestContent.java b/src/main/java/kaptainwutax/featureutils/loot/ChestContent.java new file mode 100644 index 0000000..f70b7bf --- /dev/null +++ b/src/main/java/kaptainwutax/featureutils/loot/ChestContent.java @@ -0,0 +1,107 @@ +package kaptainwutax.featureutils.loot; + +import kaptainwutax.featureutils.loot.item.Item; +import kaptainwutax.featureutils.loot.item.ItemStack; +import kaptainwutax.featureutils.structure.generator.Generator; +import kaptainwutax.mcutils.util.pos.BPos; + +import java.util.List; +import java.util.function.Predicate; + +public class ChestContent { + private final Generator.ILootType lootType; + private final ChestType chestType; + private final List items; + private final BPos pos; + private final boolean indexed; + + public ChestContent(Generator.ILootType lootType, List items, BPos pos) { + this(lootType, lootType.getChestType(), items, pos); + } + + public ChestContent(Generator.ILootType lootType, ChestType chestType, List items, BPos pos) { + this(lootType, chestType, items, pos, false); + } + + public ChestContent(Generator.ILootType lootType, List items, BPos pos, boolean indexed) { + this(lootType, lootType.getChestType(), items, pos); + } + + public ChestContent(Generator.ILootType lootType, ChestType chestType, List items, BPos pos, boolean indexed) { + this.lootType = lootType; + this.chestType = chestType; + this.items = items; + this.pos = pos; + this.indexed = indexed; + } + + public boolean contains(Item item) { + return this.containsAtLeast(item, 1); + } + + public boolean containsAtLeast(Item item, int count) { + return this.getCount(e -> e.getName().equals(item.getName())) >= count; + } + + public boolean containsExact(Item item) { + return this.containsExactlyAtLeast(item, 1); + } + + public boolean containsExactlyAtLeast(Item item, int count) { + return this.getCount(e -> e.equals(item)) >= count; + } + + public int getCount(Predicate predicate) { + return this.items.stream().filter(e -> predicate.test(e.getItem())).mapToInt(ItemStack::getCount).sum(); + } + + public Generator.ILootType getLootType() { + return lootType; + } + + public ChestType getChestType() { + return chestType; + } + + public List getItems() { + return items; + } + + public BPos getPos() { + return pos; + } + + public boolean isIndexed() { + return indexed; + } + + public enum ChestType { + SINGLE_CHEST(1), + DOUBLE_CHEST(2), + UNKNOWN(0); + + public static final int ITEMS_PER_ROW = 9; + public static final int NUMBER_ROWS = 3; + private int size; + + ChestType(int size) { + this.size = size; + } + + public void setSize(int size) { + this.size = size; + } + + public int getSize() { + return size; + } + + public int getNumberSlots() { + return this.getNumberRows() * ITEMS_PER_ROW; + } + + public int getNumberRows() { + return this.size * NUMBER_ROWS; + } + } +} diff --git a/src/main/java/kaptainwutax/featureutils/loot/ILoot.java b/src/main/java/kaptainwutax/featureutils/loot/ILoot.java index d898e9c..08f3c82 100644 --- a/src/main/java/kaptainwutax/featureutils/loot/ILoot.java +++ b/src/main/java/kaptainwutax/featureutils/loot/ILoot.java @@ -1,14 +1,15 @@ package kaptainwutax.featureutils.loot; +import kaptainwutax.featureutils.Feature; +import kaptainwutax.featureutils.GenerationContext; import kaptainwutax.featureutils.loot.item.ItemStack; import kaptainwutax.featureutils.structure.generator.Generator; +import kaptainwutax.featureutils.structure.generator.Generators; import kaptainwutax.mcutils.rand.ChunkRand; import kaptainwutax.mcutils.util.data.Pair; import kaptainwutax.mcutils.util.pos.BPos; import kaptainwutax.mcutils.util.pos.CPos; import kaptainwutax.mcutils.version.MCVersion; -import kaptainwutax.seedutils.lcg.LCG; -import kaptainwutax.seedutils.rand.JRand; import java.util.ArrayList; import java.util.HashMap; @@ -17,7 +18,7 @@ public interface ILoot { - default HashMap>> getLoot(long structureSeed, Generator generator, ChunkRand rand, boolean indexed) { + default List getLoot(long structureSeed, Generator generator, ChunkRand rand, boolean indexed) { if (!isCorrectGenerator(generator)) return null; List> lootPositions = generator.getLootPos(); @@ -39,11 +40,11 @@ default HashMap>> getLoot(long structu index += 1; } } - HashMap>> result = new HashMap<>(); + List result = new ArrayList<>(); for (Generator.ILootType lootType : chestDataHashMap.keySet()) { List chests = chestDataHashMap.get(lootType); for (ChestData chestData : chests) { - CPos chunkChestPos = chestData.getcPos(); + CPos chunkChestPos = chestData.getChunkPos(); rand.setDecoratorSeed(structureSeed, chunkChestPos.getX() * 16, chunkChestPos.getZ() * 16, this.getDecorationSalt(), this.getVersion()); SpecificCalls calls = this.getSpecificCalls(); if (calls != null) calls.run(generator, rand); @@ -51,12 +52,52 @@ default HashMap>> getLoot(long structu rand.advance(chestData.getIndex() * 2L); LootContext context = new LootContext(rand.nextLong(), this.getVersion()); List loot = indexed ? lootType.getLootTable().generateIndexed(context) : lootType.getLootTable().generate(context); - result.computeIfAbsent(lootType, k -> new ArrayList<>()).add(loot); + result.add(new ChestContent(lootType,loot,chestData.getPos(),indexed)); } } return result; } + /** + * This utility will provide the loot for a valid feature position (we don't check it tho) + * You don't have to provide anything else than + * @param worldSeed the world seed + * @param pos the position of the structure (must be a valid one) + * @param rand the rand object, used for being fast + * @param indexed if loot should be indexed + * @return a list of chestcontent + */ + default List getLootAtPos(long worldSeed,CPos pos, ChunkRand rand, boolean indexed) { + if (!(this instanceof Feature)) return null; + Feature feature= (Feature) this; + Generator.GeneratorFactory factory= Generators.get(feature.getClass()); + if (factory==null) return null; + Generator generator=factory.create(this.getVersion()); + if (generator==null) return null; + GenerationContext.Context context=feature.getContext(worldSeed); + if (context==null) return null; + if (!generator.generate(context.getGenerator(),pos)) return null; + return this.getLoot(worldSeed,generator,rand,indexed); + } + + /** + * Old method + * @param structureSeed + * @param generator + * @param rand + * @param indexed + * @return + */ + @Deprecated + default HashMap>> getLootEx(long structureSeed, Generator generator, ChunkRand rand, boolean indexed) { + HashMap>> res=new HashMap<>(); + for (ChestContent chestContent:this.getLoot(structureSeed,generator,rand,indexed)){ + res.computeIfAbsent(chestContent.getLootType(),e-> new ArrayList<>()) + .add(chestContent.getItems()); + } + return res; + } + /** * Sets the mode to advance for the number of feature in that chunk, this account for template doing twice the loot table seed, * normal structure don't, be sure to override @@ -77,24 +118,24 @@ default boolean shouldAdvanceInChunks() { SpecificCalls getSpecificCalls(); class ChestData { - int index; - CPos cPos; - BPos bpos; - int numberInChunk; + private final int index; + private final CPos chunkPos; + private final BPos pos; + private final int numberInChunk; - public ChestData(int index, CPos cPos, BPos bPos, int numberInChunk) { + public ChestData(int index, CPos chunkPos, BPos pos, int numberInChunk) { this.index = index; - this.cPos = cPos; - this.bpos = bPos; + this.chunkPos = chunkPos; + this.pos = pos; this.numberInChunk = numberInChunk; } - public BPos getBpos() { - return bpos; + public BPos getPos() { + return pos; } - public CPos getcPos() { - return cPos; + public CPos getChunkPos() { + return chunkPos; } public int getIndex() { @@ -109,8 +150,8 @@ public int getNumberInChunk() { public String toString() { return "ChestData{" + "index=" + index + - ", cPos=" + cPos + - ", bpos=" + bpos + + ", cPos=" + chunkPos + + ", bpos=" + pos + ", numberInChunk=" + numberInChunk + '}'; } diff --git a/src/main/java/kaptainwutax/featureutils/misc/SlimeChunk.java b/src/main/java/kaptainwutax/featureutils/misc/SlimeChunk.java index c70d979..e8e525b 100644 --- a/src/main/java/kaptainwutax/featureutils/misc/SlimeChunk.java +++ b/src/main/java/kaptainwutax/featureutils/misc/SlimeChunk.java @@ -6,7 +6,7 @@ import kaptainwutax.mcutils.state.Dimension; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; public class SlimeChunk extends Feature { @@ -46,13 +46,13 @@ public boolean canSpawn(SlimeChunk.Data data, BiomeSource source) { } @Override - public boolean canGenerate(Data data, ChunkGenerator generator) { + public boolean canGenerate(Data data, TerrainGenerator generator) { return true; } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } public SlimeChunk.Data at(int chunkX, int chunkZ, boolean isSlime) { diff --git a/src/main/java/kaptainwutax/featureutils/structure/BastionRemnant.java b/src/main/java/kaptainwutax/featureutils/structure/BastionRemnant.java index 6130f5a..9583a29 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/BastionRemnant.java +++ b/src/main/java/kaptainwutax/featureutils/structure/BastionRemnant.java @@ -39,8 +39,8 @@ public CPos getInRegion(long structureSeed, int regionX, int regionZ, ChunkRand } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.NETHER; + public Dimension getValidDimension() { + return Dimension.NETHER; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/BuriedTreasure.java b/src/main/java/kaptainwutax/featureutils/structure/BuriedTreasure.java index 097d1b4..b2d637a 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/BuriedTreasure.java +++ b/src/main/java/kaptainwutax/featureutils/structure/BuriedTreasure.java @@ -45,8 +45,8 @@ public CPos getInRegion(long structureSeed, int regionX, int regionZ, ChunkRand } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/DesertPyramid.java b/src/main/java/kaptainwutax/featureutils/structure/DesertPyramid.java index 40ed7ec..be2d6ec 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/DesertPyramid.java +++ b/src/main/java/kaptainwutax/featureutils/structure/DesertPyramid.java @@ -27,8 +27,8 @@ public static String name() { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/EndCity.java b/src/main/java/kaptainwutax/featureutils/structure/EndCity.java index fd4f6ea..ec4931b 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/EndCity.java +++ b/src/main/java/kaptainwutax/featureutils/structure/EndCity.java @@ -13,7 +13,7 @@ import kaptainwutax.mcutils.util.pos.CPos; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; public class EndCity extends TriangularStructure implements ILoot { @@ -38,8 +38,8 @@ public boolean canStart(Data data, long structureSeed, ChunkRand rand) } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.END; + public Dimension getValidDimension() { + return Dimension.END; } @Override @@ -48,7 +48,7 @@ public boolean isValidBiome(Biome biome) { } @Override - public boolean isValidTerrain(ChunkGenerator generator, int chunkX, int chunkZ) { + public boolean isValidTerrain(TerrainGenerator generator, int chunkX, int chunkZ) { return getAverageYPosition(generator, chunkX, chunkZ) >= 60; } @@ -81,7 +81,7 @@ public SpecificCalls getSpecificCalls() { return null; } - public static int getAverageYPosition(ChunkGenerator generator, int chunkX, int chunkZ) { + public static int getAverageYPosition(TerrainGenerator generator, int chunkX, int chunkZ) { @SuppressWarnings("IntegerMultiplicationImplicitCastToLong") ChunkRand random = new ChunkRand(chunkX + chunkZ * 10387313); BlockRotation rotation = BlockRotation.getRandom(random); diff --git a/src/main/java/kaptainwutax/featureutils/structure/Fortress.java b/src/main/java/kaptainwutax/featureutils/structure/Fortress.java index f5501a7..c66d87d 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Fortress.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Fortress.java @@ -70,8 +70,8 @@ public boolean canSpawn(int chunkX, int chunkZ, BiomeSource source) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.NETHER; + public Dimension getValidDimension() { + return Dimension.NETHER; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/Igloo.java b/src/main/java/kaptainwutax/featureutils/structure/Igloo.java index c2f9bc4..2eda7f6 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Igloo.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Igloo.java @@ -44,8 +44,8 @@ public boolean hasBasement(long structureSeed, CPos cPos, ChunkRand rand) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/JunglePyramid.java b/src/main/java/kaptainwutax/featureutils/structure/JunglePyramid.java index 7c8bdfc..596141f 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/JunglePyramid.java +++ b/src/main/java/kaptainwutax/featureutils/structure/JunglePyramid.java @@ -25,8 +25,8 @@ public static String name() { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/Mansion.java b/src/main/java/kaptainwutax/featureutils/structure/Mansion.java index 84e6a90..c3ad3b0 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Mansion.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Mansion.java @@ -31,8 +31,8 @@ public boolean canSpawn(int chunkX, int chunkZ, BiomeSource source) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/Mineshaft.java b/src/main/java/kaptainwutax/featureutils/structure/Mineshaft.java index 9078536..e184a59 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Mineshaft.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Mineshaft.java @@ -36,8 +36,8 @@ public boolean canStart(Data data, long structureSeed, ChunkRand rand) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/Monument.java b/src/main/java/kaptainwutax/featureutils/structure/Monument.java index d8719d4..5e30dfd 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Monument.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Monument.java @@ -40,8 +40,8 @@ public boolean isOceanOrRiver(Biome biome) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/NetherFossil.java b/src/main/java/kaptainwutax/featureutils/structure/NetherFossil.java index a293b3a..17fbd05 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/NetherFossil.java +++ b/src/main/java/kaptainwutax/featureutils/structure/NetherFossil.java @@ -8,7 +8,7 @@ import kaptainwutax.mcutils.state.Dimension; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; public class NetherFossil extends UniformStructure { @@ -28,8 +28,8 @@ public static String name() { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.NETHER; + public Dimension getValidDimension() { + return Dimension.NETHER; } @Override @@ -38,7 +38,7 @@ public boolean isValidBiome(Biome biome) { } @Override - public boolean isValidTerrain(ChunkGenerator generator, int chunkX, int chunkZ) { + public boolean isValidTerrain(TerrainGenerator generator, int chunkX, int chunkZ) { if (generator==null) return true; ChunkRand rand=new ChunkRand(); rand.setCarverSeed(generator.getWorldSeed(),chunkX,chunkZ,this.getVersion()); diff --git a/src/main/java/kaptainwutax/featureutils/structure/OceanRuin.java b/src/main/java/kaptainwutax/featureutils/structure/OceanRuin.java index a437b2f..e2a4c0b 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/OceanRuin.java +++ b/src/main/java/kaptainwutax/featureutils/structure/OceanRuin.java @@ -25,8 +25,8 @@ public static String name() { @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/PillagerOutpost.java b/src/main/java/kaptainwutax/featureutils/structure/PillagerOutpost.java index f64bdc8..7b7f81c 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/PillagerOutpost.java +++ b/src/main/java/kaptainwutax/featureutils/structure/PillagerOutpost.java @@ -88,8 +88,8 @@ public boolean canSpawn(int chunkX, int chunkZ, BiomeSource source) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/RuinedPortal.java b/src/main/java/kaptainwutax/featureutils/structure/RuinedPortal.java index 73a0dc0..6e9b4cc 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/RuinedPortal.java +++ b/src/main/java/kaptainwutax/featureutils/structure/RuinedPortal.java @@ -8,7 +8,7 @@ import kaptainwutax.mcutils.state.Dimension; import kaptainwutax.mcutils.version.MCVersion; import kaptainwutax.mcutils.version.VersionMap; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; public class RuinedPortal extends UniformStructure implements ILoot { @@ -44,13 +44,9 @@ public static VersionMap getConfigs(Dimension dimension) return new VersionMap<>(); } - public Dimension getDimension() { - return this.dimension; - } - @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == this.getDimension(); + public Dimension getValidDimension() { + return this.dimension; } @Override @@ -59,9 +55,9 @@ public boolean isValidBiome(Biome biome) { } @Override - public boolean isValidTerrain(ChunkGenerator generator, int chunkX, int chunkZ) { - RuinedPortalGenerator ruinedPortalGenerator=new RuinedPortalGenerator(this.getVersion()); - return ruinedPortalGenerator.generate(generator,chunkX,chunkZ); + public boolean isValidTerrain(TerrainGenerator generator, int chunkX, int chunkZ) { + RuinedPortalGenerator ruinedPortalGenerator = new RuinedPortalGenerator(this.getVersion()); + return ruinedPortalGenerator.generate(generator, chunkX, chunkZ); } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/Shipwreck.java b/src/main/java/kaptainwutax/featureutils/structure/Shipwreck.java index d310700..8958462 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Shipwreck.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Shipwreck.java @@ -36,8 +36,8 @@ public boolean canStart(Data data, long structureSeed, ChunkRand rand } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/Stronghold.java b/src/main/java/kaptainwutax/featureutils/structure/Stronghold.java index ecbb2db..7290bba 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Stronghold.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Stronghold.java @@ -148,8 +148,8 @@ public boolean canSpawn(int chunkX, int chunkZ, BiomeSource source) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } private Set getValidBiomes() { diff --git a/src/main/java/kaptainwutax/featureutils/structure/Structure.java b/src/main/java/kaptainwutax/featureutils/structure/Structure.java index baa87bc..dd2538f 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Structure.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Structure.java @@ -5,7 +5,7 @@ import kaptainwutax.featureutils.Feature; import kaptainwutax.mcutils.util.pos.CPos; import kaptainwutax.mcutils.version.MCVersion; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; import java.util.HashMap; import java.util.Map; @@ -80,19 +80,19 @@ public boolean canSpawn(int chunkX, int chunkZ, BiomeSource source) { @Override - public final boolean canGenerate(D data, ChunkGenerator generator) { + public final boolean canGenerate(D data, TerrainGenerator generator) { return this.canGenerate(data.chunkX, data.chunkZ, generator); } - public boolean canGenerate(CPos cPos, ChunkGenerator generator) { + public boolean canGenerate(CPos cPos, TerrainGenerator generator) { return this.canGenerate(cPos.getX(), cPos.getZ(), generator); } - public boolean canGenerate(int chunkX, int chunkZ, ChunkGenerator generator) { + public boolean canGenerate(int chunkX, int chunkZ, TerrainGenerator generator) { return this.isValidTerrain(generator, chunkX, chunkZ); } - public boolean isValidTerrain(ChunkGenerator generator, int chunkX, int chunkZ) { + public boolean isValidTerrain(TerrainGenerator generator, int chunkX, int chunkZ) { return true; } diff --git a/src/main/java/kaptainwutax/featureutils/structure/SwampHut.java b/src/main/java/kaptainwutax/featureutils/structure/SwampHut.java index 95a7379..3660ec6 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/SwampHut.java +++ b/src/main/java/kaptainwutax/featureutils/structure/SwampHut.java @@ -25,8 +25,8 @@ public static String name() { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/Village.java b/src/main/java/kaptainwutax/featureutils/structure/Village.java index 1cf25f2..797e26c 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/Village.java +++ b/src/main/java/kaptainwutax/featureutils/structure/Village.java @@ -64,8 +64,8 @@ public boolean isZombieVillage(long structureSeed, CPos cPos, ChunkRand rand) { } @Override - public boolean isValidDimension(Dimension dimension) { - return dimension == Dimension.OVERWORLD; + public Dimension getValidDimension() { + return Dimension.OVERWORLD; } @Override diff --git a/src/main/java/kaptainwutax/featureutils/structure/generator/Generator.java b/src/main/java/kaptainwutax/featureutils/structure/generator/Generator.java index c3f0604..e7ed91d 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/generator/Generator.java +++ b/src/main/java/kaptainwutax/featureutils/structure/generator/Generator.java @@ -1,6 +1,7 @@ package kaptainwutax.featureutils.structure.generator; import kaptainwutax.biomeutils.source.BiomeSource; +import kaptainwutax.featureutils.loot.ChestContent; import kaptainwutax.featureutils.loot.LootTable; import kaptainwutax.featureutils.loot.entry.ItemEntry; import kaptainwutax.featureutils.loot.item.Item; @@ -10,7 +11,7 @@ import kaptainwutax.mcutils.util.pos.BPos; import kaptainwutax.mcutils.util.pos.CPos; import kaptainwutax.mcutils.version.MCVersion; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; import java.util.Arrays; import java.util.HashSet; @@ -32,23 +33,23 @@ public MCVersion getVersion() { public boolean generate(long worldSeed, Dimension dimension, int chunkX, int chunkZ) { BiomeSource biomeSource = BiomeSource.of(dimension, this.getVersion(), worldSeed); - ChunkGenerator generator=ChunkGenerator.of(dimension,biomeSource); + TerrainGenerator generator=TerrainGenerator.of(dimension,biomeSource); return this.generate(generator,chunkX,chunkZ); } - public boolean generate(ChunkGenerator generator, CPos cPos) { + public boolean generate(TerrainGenerator generator, CPos cPos) { return this.generate(generator, cPos, new ChunkRand()); } - public boolean generate(ChunkGenerator generator, int chunkX, int chunkZ) { + public boolean generate(TerrainGenerator generator, int chunkX, int chunkZ) { return this.generate(generator, chunkX, chunkZ, new ChunkRand()); } - public boolean generate(ChunkGenerator generator, CPos cPos, ChunkRand rand) { + public boolean generate(TerrainGenerator generator, CPos cPos, ChunkRand rand) { return this.generate(generator, cPos.getX(), cPos.getZ(), rand); } - public abstract boolean generate(ChunkGenerator generator, int chunkX, int chunkZ, ChunkRand rand); + public abstract boolean generate(TerrainGenerator generator, int chunkX, int chunkZ, ChunkRand rand); public abstract List> getChestsPos(); @@ -60,6 +61,7 @@ public List> getChestsChunkPos() { public interface ILootType { LootTable getLootTable(); + ChestContent.ChestType getChestType(); } @FunctionalInterface diff --git a/src/main/java/kaptainwutax/featureutils/structure/generator/Generators.java b/src/main/java/kaptainwutax/featureutils/structure/generator/Generators.java index 9f122c6..2485a92 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/generator/Generators.java +++ b/src/main/java/kaptainwutax/featureutils/structure/generator/Generators.java @@ -1,6 +1,7 @@ package kaptainwutax.featureutils.structure.generator; import kaptainwutax.featureutils.Feature; +import kaptainwutax.featureutils.loot.ILoot; import kaptainwutax.featureutils.structure.*; import kaptainwutax.featureutils.structure.generator.structure.*; diff --git a/src/main/java/kaptainwutax/featureutils/structure/generator/structure/BuriedTreasureGenerator.java b/src/main/java/kaptainwutax/featureutils/structure/generator/structure/BuriedTreasureGenerator.java index 9235556..7c8e539 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/generator/structure/BuriedTreasureGenerator.java +++ b/src/main/java/kaptainwutax/featureutils/structure/generator/structure/BuriedTreasureGenerator.java @@ -1,5 +1,6 @@ package kaptainwutax.featureutils.structure.generator.structure; +import kaptainwutax.featureutils.loot.ChestContent; import kaptainwutax.featureutils.loot.LootTable; import kaptainwutax.featureutils.loot.MCLootTables; import kaptainwutax.featureutils.structure.generator.Generator; @@ -8,7 +9,7 @@ import kaptainwutax.mcutils.util.pos.BPos; import kaptainwutax.mcutils.util.pos.CPos; import kaptainwutax.mcutils.version.MCVersion; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; import java.util.Collections; import java.util.List; @@ -21,7 +22,7 @@ public BuriedTreasureGenerator(MCVersion version) { } @Override - public boolean generate(ChunkGenerator generator, int chunkX, int chunkZ, ChunkRand rand) { + public boolean generate(TerrainGenerator generator, int chunkX, int chunkZ, ChunkRand rand) { cPos = new CPos(chunkX, chunkZ); return true; } @@ -42,18 +43,26 @@ public ILootType[] getLootTypes() { } public enum LootType implements ILootType { - BURIED_CHEST(MCLootTables.BURIED_TREASURE_CHEST), + BURIED_CHEST(MCLootTables.BURIED_TREASURE_CHEST, ChestContent.ChestType.SINGLE_CHEST), ; public final LootTable lootTable; + public final ChestContent.ChestType chestType; - LootType(LootTable lootTable) { + LootType(LootTable lootTable,ChestContent.ChestType chestType) { this.lootTable = lootTable; + this.chestType=chestType; } + @Override public LootTable getLootTable() { return lootTable; } + + @Override + public ChestContent.ChestType getChestType() { + return chestType; + } } } diff --git a/src/main/java/kaptainwutax/featureutils/structure/generator/structure/DesertPyramidGenerator.java b/src/main/java/kaptainwutax/featureutils/structure/generator/structure/DesertPyramidGenerator.java index f2471e4..57110d5 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/generator/structure/DesertPyramidGenerator.java +++ b/src/main/java/kaptainwutax/featureutils/structure/generator/structure/DesertPyramidGenerator.java @@ -1,5 +1,6 @@ package kaptainwutax.featureutils.structure.generator.structure; +import kaptainwutax.featureutils.loot.ChestContent; import kaptainwutax.featureutils.loot.LootTable; import kaptainwutax.featureutils.loot.MCLootTables; import kaptainwutax.featureutils.structure.generator.Generator; @@ -9,7 +10,7 @@ import kaptainwutax.mcutils.util.pos.BPos; import kaptainwutax.mcutils.util.pos.CPos; import kaptainwutax.mcutils.version.MCVersion; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; import java.util.ArrayList; import java.util.List; @@ -23,7 +24,7 @@ public DesertPyramidGenerator(MCVersion version) { } @Override - public boolean generate(ChunkGenerator generator, int chunkX, int chunkZ, ChunkRand rand) { + public boolean generate(TerrainGenerator generator, int chunkX, int chunkZ, ChunkRand rand) { // fixme actually compute the BPos temp = new CPos(chunkX, chunkZ); piece = new BlockBox(temp, temp.add(1, 1)); @@ -53,22 +54,31 @@ public ILootType[] getLootTypes() { return LootType.values(); } + public enum LootType implements ILootType { - CHEST_1(MCLootTables.DESERT_PYRAMID_CHEST), - CHEST_2(MCLootTables.DESERT_PYRAMID_CHEST), - CHEST_3(MCLootTables.DESERT_PYRAMID_CHEST), - CHEST_4(MCLootTables.DESERT_PYRAMID_CHEST), + CHEST_1(MCLootTables.DESERT_PYRAMID_CHEST, ChestContent.ChestType.SINGLE_CHEST), + CHEST_2(MCLootTables.DESERT_PYRAMID_CHEST, ChestContent.ChestType.SINGLE_CHEST), + CHEST_3(MCLootTables.DESERT_PYRAMID_CHEST, ChestContent.ChestType.SINGLE_CHEST), + CHEST_4(MCLootTables.DESERT_PYRAMID_CHEST, ChestContent.ChestType.SINGLE_CHEST), ; public final LootTable lootTable; + public final ChestContent.ChestType chestType; - LootType(LootTable lootTable) { + LootType(LootTable lootTable, ChestContent.ChestType chestType) { this.lootTable = lootTable; + this.chestType = chestType; } + @Override public LootTable getLootTable() { return lootTable; } + + @Override + public ChestContent.ChestType getChestType() { + return chestType; + } } } diff --git a/src/main/java/kaptainwutax/featureutils/structure/generator/structure/EndCityGenerator.java b/src/main/java/kaptainwutax/featureutils/structure/generator/structure/EndCityGenerator.java index 0578360..5186697 100644 --- a/src/main/java/kaptainwutax/featureutils/structure/generator/structure/EndCityGenerator.java +++ b/src/main/java/kaptainwutax/featureutils/structure/generator/structure/EndCityGenerator.java @@ -1,5 +1,6 @@ package kaptainwutax.featureutils.structure.generator.structure; +import kaptainwutax.featureutils.loot.ChestContent; import kaptainwutax.featureutils.loot.LootTable; import kaptainwutax.featureutils.loot.MCLootTables; import kaptainwutax.featureutils.loot.item.Item; @@ -13,7 +14,7 @@ import kaptainwutax.mcutils.util.data.Pair; import kaptainwutax.mcutils.util.pos.BPos; import kaptainwutax.mcutils.version.MCVersion; -import kaptainwutax.terrainutils.ChunkGenerator; +import kaptainwutax.terrainutils.TerrainGenerator; import java.util.*; @@ -35,8 +36,8 @@ public List