use of net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class SyncMultiModelPacket method createS2CPacket.
public static PacketByteBuf createS2CPacket(Entity entity, IHasMultiModel hasMultiModel) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeInt(entity.getEntityId());
passedData.writeString(hasMultiModel.getTextureHolder(Layer.SKIN, Part.HEAD).getTextureName());
for (Part part : Part.values()) {
passedData.writeString(hasMultiModel.getTextureHolder(Layer.INNER, part).getTextureName());
}
passedData.writeEnumConstant(hasMultiModel.getColor());
passedData.writeBoolean(hasMultiModel.isContract());
return passedData;
}
use of net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part 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);
}
use of net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part 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));
}
}
use of net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class SyncMultiModelPacket method createC2SPacket.
public static PacketByteBuf createC2SPacket(Entity entity, IHasMultiModel hasMultiModel) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeInt(entity.getEntityId());
passedData.writeString(hasMultiModel.getTextureHolder(Layer.SKIN, Part.HEAD).getTextureName());
for (Part part : Part.values()) {
passedData.writeString(hasMultiModel.getTextureHolder(Layer.INNER, part).getTextureName());
}
passedData.writeEnumConstant(hasMultiModel.getColor());
passedData.writeBoolean(hasMultiModel.isContract());
return passedData;
}
use of net.sistr.littlemaidmodelloader.entity.compound.IHasMultiModel.Part in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class SyncMultiModelPacket method receiveS2CPacket.
@Environment(EnvType.CLIENT)
public static void receiveS2CPacket(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
int entityId = buf.readInt();
String textureName = buf.readString();
ArmorSets<String> armorTextureName = new ArmorSets<>();
for (Part part : Part.values()) {
armorTextureName.setArmor(buf.readString(), part);
}
TextureColors color = buf.readEnumConstant(TextureColors.class);
boolean isContract = buf.readBoolean();
client.execute(() -> applyMultiModelClient(entityId, isContract, color, textureName, armorTextureName));
}
Aggregations