Search in sources :

Example 1 with LMTextureManager

use of net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class SyncMultiModelPacket method applyMultiModelServer.

// クライアントに倣って分離
public static void applyMultiModelServer(PlayerEntity player, int entityId, boolean isContract, TextureColors color, String textureName, ArmorSets<String> armorTextureName) {
    Entity entity = player.world.getEntityById(entityId);
    if (!(entity instanceof IHasMultiModel))
        return;
    IHasMultiModel multiModel = (IHasMultiModel) entity;
    multiModel.setContract(isContract);
    multiModel.setColor(color);
    LMTextureManager textureManager = LMTextureManager.INSTANCE;
    textureManager.getTexture(textureName).filter(textureHolder -> multiModel.isAllowChangeTexture(entity, textureHolder, Layer.SKIN, Part.HEAD)).ifPresent(textureHolder -> multiModel.setTextureHolder(textureHolder, Layer.SKIN, Part.HEAD));
    for (Part part : Part.values()) {
        String armorName = armorTextureName.getArmor(part).orElseThrow(() -> new IllegalStateException("テクスチャが存在しません。"));
        textureManager.getTexture(armorName).filter(textureHolder -> multiModel.isAllowChangeTexture(entity, textureHolder, Layer.INNER, part)).ifPresent(textureHolder -> multiModel.setTextureHolder(textureHolder, Layer.INNER, part));
    }
    sendS2CPacket(entity, multiModel);
}
Also used : IHasMultiModel(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel) Entity(net.minecraft.entity.Entity) PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) ClientPlayNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking) PlayerEntity(net.minecraft.entity.player.PlayerEntity) IHasMultiModel(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel) World(net.minecraft.world.World) Layer(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Layer) LMTextureManager(net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager) Environment(net.fabricmc.api.Environment) PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerLookup(net.fabricmc.fabric.api.networking.v1.PlayerLookup) Unpooled(io.netty.buffer.Unpooled) MinecraftServer(net.minecraft.server.MinecraftServer) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LittleMaidModelLoader(net.sistr.littlemaidmodelloader.LittleMaidModelLoader) Part(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part) TextureColors(net.sistr.littlemaidmodelloader.resource.util.TextureColors) ServerPlayNetworking(net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking) EnvType(net.fabricmc.api.EnvType) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) ArmorSets(net.sistr.littlemaidmodelloader.resource.util.ArmorSets) ServerPlayNetworkHandler(net.minecraft.server.network.ServerPlayNetworkHandler) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Part(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part) LMTextureManager(net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager)

Example 2 with LMTextureManager

use of net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class SyncMultiModelPacket method applyMultiModelClient.

// context.getTaskQueue().execute()の中では@Environmentの効力が及ばないため別メソッドに分離
@Environment(EnvType.CLIENT)
public static void applyMultiModelClient(int entityId, boolean isContract, TextureColors color, String textureName, ArmorSets<String> armorTextureName) {
    World world = MinecraftClient.getInstance().world;
    if (world == null)
        return;
    Entity entity = world.getEntityById(entityId);
    if (!(entity instanceof IHasMultiModel))
        return;
    IHasMultiModel multiModel = (IHasMultiModel) entity;
    multiModel.setContract(isContract);
    multiModel.setColor(color);
    LMTextureManager textureManager = LMTextureManager.INSTANCE;
    textureManager.getTexture(textureName).filter(textureHolder -> multiModel.isAllowChangeTexture(entity, textureHolder, Layer.SKIN, Part.HEAD)).ifPresent(textureHolder -> multiModel.setTextureHolder(textureHolder, Layer.SKIN, Part.HEAD));
    for (Part part : Part.values()) {
        String armorName = armorTextureName.getArmor(part).orElseThrow(() -> new IllegalStateException("テクスチャが存在しません。"));
        textureManager.getTexture(armorName).filter(textureHolder -> multiModel.isAllowChangeTexture(entity, textureHolder, Layer.INNER, part)).ifPresent(textureHolder -> multiModel.setTextureHolder(textureHolder, Layer.INNER, part));
    }
}
Also used : IHasMultiModel(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel) Entity(net.minecraft.entity.Entity) PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) ClientPlayNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking) PlayerEntity(net.minecraft.entity.player.PlayerEntity) IHasMultiModel(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel) World(net.minecraft.world.World) Layer(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Layer) LMTextureManager(net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager) Environment(net.fabricmc.api.Environment) PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerLookup(net.fabricmc.fabric.api.networking.v1.PlayerLookup) Unpooled(io.netty.buffer.Unpooled) MinecraftServer(net.minecraft.server.MinecraftServer) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LittleMaidModelLoader(net.sistr.littlemaidmodelloader.LittleMaidModelLoader) Part(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part) TextureColors(net.sistr.littlemaidmodelloader.resource.util.TextureColors) ServerPlayNetworking(net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking) EnvType(net.fabricmc.api.EnvType) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) ArmorSets(net.sistr.littlemaidmodelloader.resource.util.ArmorSets) ServerPlayNetworkHandler(net.minecraft.server.network.ServerPlayNetworkHandler) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Part(net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part) World(net.minecraft.world.World) LMTextureManager(net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager) Environment(net.fabricmc.api.Environment)

Example 3 with LMTextureManager

use of net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class MultiModelEntity method readCustomPacket.

@Override
public void readCustomPacket(PacketByteBuf packet) {
    // readString()はクラ処理。このメソッドでは、クラ側なので問題なし
    setColor(packet.readEnumConstant(TextureColors.class));
    setContract(packet.readBoolean());
    LMTextureManager textureManager = LMTextureManager.INSTANCE;
    textureManager.getTexture(packet.readString()).ifPresent(textureHolder -> setTextureHolder(textureHolder, Layer.SKIN, Part.HEAD));
    for (Part part : Part.values()) {
        textureManager.getTexture(packet.readString()).ifPresent(textureHolder -> setTextureHolder(textureHolder, Layer.INNER, part));
        textureManager.getTexture(packet.readString()).ifPresent(textureHolder -> setTextureHolder(textureHolder, Layer.OUTER, part));
    }
}
Also used : TextureColors(net.sistr.littlemaidmodelloader.resource.util.TextureColors) LMTextureManager(net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager)

Example 4 with LMTextureManager

use of net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class MultiModelEntity method readCustomDataFromTag.

@Override
public void readCustomDataFromTag(CompoundTag tag) {
    super.readCustomDataFromTag(tag);
    if (tag.contains("SkinColor")) {
        setColor(TextureColors.getColor(tag.getByte("SkinColor")));
    }
    setContract(tag.getBoolean("IsContract"));
    LMTextureManager textureManager = LMTextureManager.INSTANCE;
    if (tag.contains("SkinTexture")) {
        textureManager.getTexture(tag.getString("SkinTexture")).ifPresent(textureHolder -> setTextureHolder(textureHolder, Layer.SKIN, Part.HEAD));
    }
    for (Part part : Part.values()) {
        String inner = "ArmorTextureInner" + part.getPartName();
        String outer = "ArmorTextureOuter" + part.getPartName();
        if (tag.contains(inner)) {
            textureManager.getTexture(tag.getString(inner)).ifPresent(textureHolder -> setTextureHolder(textureHolder, Layer.INNER, part));
        }
        if (tag.contains(outer)) {
            textureManager.getTexture(tag.getString(outer)).ifPresent(textureHolder -> setTextureHolder(textureHolder, Layer.OUTER, part));
        }
    }
}
Also used : LMTextureManager(net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager)

Example 5 with LMTextureManager

use of net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class ClientSetup method onInitializeClient.

@Override
public void onInitializeClient() {
    SideChecker.init(SideChecker.Side.CLIENT);
    LMFileLoader fileLoader = LMFileLoader.INSTANCE;
    LMTextureManager textureManager = LMTextureManager.INSTANCE;
    LMSoundManager soundManager = LMSoundManager.INSTANCE;
    LMTextureLoader textureProcessor = new LMTextureLoader(textureManager);
    textureProcessor.addPathConverter("assets/", "");
    textureProcessor.addPathConverter("mob/", "minecraft/textures/entity/");
    fileLoader.addLoader(textureProcessor);
    fileLoader.addLoader(new LMSoundLoader(soundManager));
    ((AddableResourcePackProvider) MinecraftClient.getInstance().getResourcePackManager()).addResourcePackProvider(new LMPackProvider());
    // モデルを読み込む
    LMModelManager modelManager = LMModelManager.INSTANCE;
    modelManager.addModel("Default", ModelLittleMaid_Orign.class);
    modelManager.addModel("SR2", ModelLittleMaid_SR2.class);
    modelManager.addModel("Aug", ModelLittleMaid_Aug.class);
    modelManager.addModel("Archetype", ModelLittleMaid_Archetype.class);
    modelManager.addModel("Steve", ModelMulti_Steve.class);
    modelManager.addModel("Stef", ModelMulti_Stef.class);
    modelManager.addModel("Alicia", new MultiModel_Alicia(), new MultiModel_Alicia(), new MultiModel_Alicia());
    modelManager.setDefaultModel(modelManager.getModel("Default", IHasMultiModel.Layer.SKIN).orElseThrow(RuntimeException::new));
    fileLoader.load();
    Networking.INSTANCE.init();
    EntityRendererRegistry.INSTANCE.register(Registration.MULTI_MODEL_ENTITY, (a, b) -> new MultiModelRenderer<>(a));
    EntityRendererRegistry.INSTANCE.register(Registration.DUMMY_MODEL_ENTITY, (a, b) -> new MultiModelRenderer<>(a));
}
Also used : LMPackProvider(net.sistr.littlemaidmodelloader.client.LMPackProvider) LMSoundLoader(net.sistr.littlemaidmodelloader.client.resource.loader.LMSoundLoader) LMTextureLoader(net.sistr.littlemaidmodelloader.client.resource.loader.LMTextureLoader) MultiModel_Alicia(net.sistr.littlemaidmodelloader.multimodel.MultiModel_Alicia) LMFileLoader(net.sistr.littlemaidmodelloader.resource.loader.LMFileLoader) AddableResourcePackProvider(net.sistr.littlemaidmodelloader.client.AddableResourcePackProvider) LMModelManager(net.sistr.littlemaidmodelloader.resource.manager.LMModelManager) LMSoundManager(net.sistr.littlemaidmodelloader.client.resource.manager.LMSoundManager) LMTextureManager(net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager)

Aggregations

LMTextureManager (net.sistr.littlemaidmodelloader.resource.manager.LMTextureManager)5 TextureColors (net.sistr.littlemaidmodelloader.resource.util.TextureColors)3 Unpooled (io.netty.buffer.Unpooled)2 EnvType (net.fabricmc.api.EnvType)2 Environment (net.fabricmc.api.Environment)2 ClientPlayNetworking (net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking)2 PacketSender (net.fabricmc.fabric.api.networking.v1.PacketSender)2 PlayerLookup (net.fabricmc.fabric.api.networking.v1.PlayerLookup)2 ServerPlayNetworking (net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking)2 MinecraftClient (net.minecraft.client.MinecraftClient)2 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)2 Entity (net.minecraft.entity.Entity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 PacketByteBuf (net.minecraft.network.PacketByteBuf)2 MinecraftServer (net.minecraft.server.MinecraftServer)2 ServerPlayNetworkHandler (net.minecraft.server.network.ServerPlayNetworkHandler)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 Identifier (net.minecraft.util.Identifier)2 World (net.minecraft.world.World)2 LittleMaidModelLoader (net.sistr.littlemaidmodelloader.LittleMaidModelLoader)2