thanks NeoFrogge NeoForge NeonForges
This commit is contained in:
parent
3dd7583d4e
commit
d38c780fdd
@ -15,9 +15,11 @@ import net.minecraft.core.registries.Registries
|
|||||||
import net.minecraft.nbt.NbtOps
|
import net.minecraft.nbt.NbtOps
|
||||||
import net.minecraft.nbt.Tag
|
import net.minecraft.nbt.Tag
|
||||||
import net.minecraft.network.FriendlyByteBuf
|
import net.minecraft.network.FriendlyByteBuf
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.network.chat.MutableComponent
|
import net.minecraft.network.chat.MutableComponent
|
||||||
import net.minecraft.network.chat.contents.PlainTextContents
|
import net.minecraft.network.chat.contents.PlainTextContents
|
||||||
import net.minecraft.network.chat.contents.TranslatableContents
|
import net.minecraft.network.chat.contents.TranslatableContents
|
||||||
|
import net.minecraft.network.chat.contents.TranslatableContents.isAllowedPrimitiveArgument
|
||||||
import net.minecraft.resources.ResourceKey
|
import net.minecraft.resources.ResourceKey
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.sounds.SoundEvent
|
import net.minecraft.sounds.SoundEvent
|
||||||
@ -77,7 +79,11 @@ fun <V : Any> Codec<V>.fromNetwork(buff: FriendlyByteBuf): V {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1.19 being 1.19
|
// 1.19 being 1.19
|
||||||
fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, null, values))
|
fun TranslatableComponent(key: String, vararg values: Any): MutableComponent {
|
||||||
|
// thanks NeoFrogge NeoForge NeonForges
|
||||||
|
return MutableComponent.create(TranslatableContents(key, null, values.map { if (it !is Component && !isAllowedPrimitiveArgument(it)) it.toString() else it }.toTypedArray()))
|
||||||
|
}
|
||||||
|
|
||||||
fun TextComponent(value: String): MutableComponent = MutableComponent.create(PlainTextContents.create(value))
|
fun TextComponent(value: String): MutableComponent = MutableComponent.create(PlainTextContents.create(value))
|
||||||
|
|
||||||
fun <T : Any> Registry<T>.getKeyNullable(value: T): ResourceLocation? {
|
fun <T : Any> Registry<T>.getKeyNullable(value: T): ResourceLocation? {
|
||||||
|
Loading…
Reference in New Issue
Block a user