-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
95 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
src/main/java/io/glossnyx/disco/mixin/LootTableAccessor.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.auxves.disco | ||
|
||
import net.fabricmc.loader.api.FabricLoader | ||
import net.fabricmc.loader.api.metadata.ModMetadata | ||
import net.minecraft.util.Identifier | ||
|
||
data class Addon( | ||
val id: String, | ||
val discs: List<Disc>, | ||
) | ||
|
||
private fun ModMetadata.toAddon(): Addon { | ||
val custom = getCustomValue(modName).asObject | ||
|
||
val discs = custom.get("discs").asArray.map { | ||
val obj = it.asObject | ||
val identifier = Identifier(id, obj.get("id").asString) | ||
val duration = obj.get("duration").asNumber.toInt() | ||
|
||
Disc(identifier, duration) | ||
} | ||
|
||
return Addon(id, discs) | ||
} | ||
|
||
val addons = FabricLoader.getInstance().allMods | ||
.filter { it.metadata.customValues.containsKey(modName) } | ||
.map { it.metadata.toAddon() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.auxves.disco | ||
|
||
import net.minecraft.item.Item | ||
import net.minecraft.item.ItemGroup | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.item.MusicDiscItem | ||
import net.minecraft.sound.SoundEvent | ||
import net.minecraft.text.Text | ||
import net.minecraft.util.Identifier | ||
import net.minecraft.util.Rarity | ||
|
||
private val settings = Item.Settings() | ||
.group(ItemGroup.MISC) | ||
.rarity(Rarity.RARE) | ||
.maxCount(1) | ||
|
||
class Disc(val id: Identifier, duration: Int) : MusicDiscItem(15, SoundEvent(id), settings, duration) { | ||
override fun getName(stack: ItemStack?): Text { | ||
return Text.translatable("item.minecraft.music_disc_cat") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package dev.auxves.disco | ||
|
||
import net.minecraft.util.registry.Registry | ||
|
||
const val modName = "disco" | ||
|
||
@Suppress("unused") | ||
fun init() { | ||
addons.flatMap { it.discs }.forEach { | ||
Registry.register(Registry.ITEM, it.id, it) | ||
} | ||
|
||
println("Disco loaded!") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters