diff --git a/gradle.properties b/gradle.properties index cd31beb..d275934 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ kffVersion=1.10.0 # https://maven.apache.org/guides/mini/guide-naming-conventions.html package=com.theonlytails artifact=loottables -modVersion=0.1.2 +modVersion=0.1.3 # Misc author=TheOnlyTails # Config diff --git a/src/main/kotlin/com/theonlytails/loottables/LootEntries.kt b/src/main/kotlin/com/theonlytails/loottables/LootEntries.kt index 167d481..f463a6c 100644 --- a/src/main/kotlin/com/theonlytails/loottables/LootEntries.kt +++ b/src/main/kotlin/com/theonlytails/loottables/LootEntries.kt @@ -16,7 +16,7 @@ fun LootPool.Builder.itemEntry( @LootTablesDsl fun LootPool.Builder.itemEntry( item: IItemProvider, - body: StandaloneLootEntry.Builder<*>.() -> StandaloneLootEntry.Builder<*>, + body: StandaloneLootEntry.Builder<*>.() -> LootEntry.Builder<*>, ): LootPool.Builder = add(ItemLootEntry.lootTableItem(item).body()) @LootTablesDsl @@ -27,7 +27,7 @@ fun LootPool.Builder.tagEntry( @LootTablesDsl fun LootPool.Builder.tagEntry( tag: ITag, - body: StandaloneLootEntry.Builder<*>.() -> StandaloneLootEntry.Builder<*>, + body: StandaloneLootEntry.Builder<*>.() -> LootEntry.Builder<*>, ): LootPool.Builder = add(TagLootEntry.expandTag(tag).body()) @LootTablesDsl @@ -38,7 +38,7 @@ fun LootPool.Builder.tableEntry( @LootTablesDsl fun LootPool.Builder.tableEntry( lootTable: ResourceLocation, - body: StandaloneLootEntry.Builder<*>.() -> StandaloneLootEntry.Builder<*>, + body: StandaloneLootEntry.Builder<*>.() -> LootEntry.Builder<*>, ): LootPool.Builder = add(TableLootEntry.lootTableReference(lootTable).body()) @LootTablesDsl @@ -49,7 +49,7 @@ fun LootPool.Builder.dynamicEntry( @LootTablesDsl fun LootPool.Builder.dynamicEntry( id: ResourceLocation, - body: StandaloneLootEntry.Builder<*>.() -> StandaloneLootEntry.Builder<*>, + body: StandaloneLootEntry.Builder<*>.() -> LootEntry.Builder<*>, ): LootPool.Builder = add(DynamicLootEntry.dynamicEntry(id).body()) @LootTablesDsl @@ -75,5 +75,5 @@ fun LootEntry.Builder<*>.condition(getCondition: () -> ILootCondition.IBuilder): `when`(getCondition()) @LootTablesDsl -fun StandaloneLootEntry.Builder<*>.function(getFunction: () -> ILootFunction.IBuilder): LootEntry.Builder<*> = +fun StandaloneLootEntry.Builder<*>.function(getFunction: () -> ILootFunction.IBuilder): StandaloneLootEntry.Builder<*> = apply(getFunction()) \ No newline at end of file diff --git a/src/test/kotlin/LootTablesTest.kt b/src/test/kotlin/LootTablesTest.kt index 94d57ad..32a2d87 100644 --- a/src/test/kotlin/LootTablesTest.kt +++ b/src/test/kotlin/LootTablesTest.kt @@ -1,28 +1,26 @@ +import com.google.gson.Gson import com.theonlytails.loottables.* import io.kotest.core.spec.style.StringSpec import net.minecraft.block.Blocks -import net.minecraft.block.SlabBlock import net.minecraft.loot.LootParameterSets.BLOCK -import net.minecraft.state.properties.SlabType +import net.minecraft.loot.LootSerializers +import net.minecraft.loot.functions.CopyName + +val gson: Gson = LootSerializers.createLootTableSerializer() + .disableHtmlEscaping() + .setPrettyPrinting() + .create() class LootTablesTest : StringSpec({ - "drop slabs" { - lootTable(BLOCK) { + "loot entries with functions" { + println(gson.toJson(lootTable(BLOCK) { pool { - itemEntry(Blocks.ACACIA_SLAB) - - condition { survivesExplosion() } - function { - setCount(constantRange(2)) { - condition { - blockStateProperty(Blocks.ACACIA_SLAB).setProperties( - stateProperties { hasProperty(SlabBlock.TYPE, SlabType.DOUBLE) } - ) - } - } + itemEntry(Blocks.CHEST) { + function { copyName(CopyName.Source.BLOCK_ENTITY) } } + condition { survivesExplosion() } } - } + })) } } ) \ No newline at end of file