Code/net/minecraft/core/ClientAsset.java

19 lines
858 B
Java

package net.minecraft.core;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceLocation;
public record ClientAsset(ResourceLocation id, ResourceLocation texturePath) {
public static final Codec<ClientAsset> CODEC = ResourceLocation.CODEC.xmap(ClientAsset::new, ClientAsset::id);
public static final MapCodec<ClientAsset> DEFAULT_FIELD_CODEC = CODEC.fieldOf("asset_id");
public static final StreamCodec<ByteBuf, ClientAsset> STREAM_CODEC = StreamCodec.composite(
ResourceLocation.STREAM_CODEC, ClientAsset::id, ClientAsset::new
);
public ClientAsset(ResourceLocation p_394229_) {
this(p_394229_, p_394229_.withPath(p_392243_ -> "textures/" + p_392243_ + ".png"));
}
}